Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

481
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!