Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

483
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda