Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

477
Vistas
starting a next server on cpanel throwing 503 service unavailable

I'm attempting to deploy a NextJS app on my shared hosting server using the cPanel Setup Node.JS App section, but when I start the build - despite getting ready on http://localhost:3000 - the site throws a 503 error.

I've uploaded the build folder alongside the next.config.js, package-lock.json, package.json and server.js to the application root, and this is my current file structure:

next_main
    build (.next folder)
    node_modules
    next.config.js
    package-lock.json
    package.json
    server.js

This is my server.js file (exactly the same as what Next provided in their custom server docs):

const { createServer } = require("http");
const { parse } = require("url");
const next = require("next");

const dev = process.env.NODE_ENV !== "production";
const hostname = "localhost";
const port = 3000;

const app = next({ dev, hostname, port });
const handle = app.getRequestHandler();

app.prepare().then(() => {
    createServer(async (request, response) => {
        try{
            const parsedURL = parse(request.url, true);
            const { pathname, query } = parsedURL;

            switch(pathname){
                case "/a":
                case "/b":
                    await app.render(request, response, pathname, query);
                    break;
                default:
                    await handle(request, response, parsedURL);
            }
        } catch(error){
            console.error("Error occurred.", request.url, error);
            response.statusCode = 500;
            response.end("Internal server error.");
        }
    }).listen(port, error => {
        if(error) throw error;
        console.log(`> Ready on http://${hostname}:${port}`);
    });
}).catch(error => {
    if(error) throw error;
});

Failed to load next.config.js was also output in my stderr file, despite next.config.js being provided.

I've attached the current settings I have applied in my cPanel.

Please note that I do not have root access to the terminal, and am restricted to the next_main environment when running any NPM scripts.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your build has been created in .next folder but it needs to be started with npm start and your domain should point to that port 3000(or whichever port you are running it on).

Make sure you are not pointing your domain to .next directory but at the port at which it is running and make sure server is also stared.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda