title: starting a next server on cpanel throwing 503 service unavailable
body: <p>I'm attempting to deploy a <strong>NextJS</strong> app on my shared hosting server using the <strong>cPanel</strong> <em>Setup Node.JS App</em> section, but when I start the build - despite getting <code>ready on http://localhost:3000</code> - the site throws a <strong>503</strong> error.</p>
  <p>I've uploaded the build folder alongside the <code>next.config.js</code>, <code>package-lock.json</code>, <code>package.json</code> and <code>server.js</code> to the application root, and this is my current file structure:</p>
  <pre><code>next_main
      build (.next folder)
      node_modules
      next.config.js
      package-lock.json
      package.json
      server.js
  </code></pre>
  <p>This is my <code>server.js</code> file (exactly the same as what Next provided in their custom server docs):</p>
  <pre><code>const { createServer } = require(&quot;http&quot;);
  const { parse } = require(&quot;url&quot;);
  const next = require(&quot;next&quot;);
  
  const dev = process.env.NODE_ENV !== &quot;production&quot;;
  const hostname = &quot;localhost&quot;;
  const port = 3000;
  
  const app = next({ dev, hostname, port });
  const handle = app.getRequestHandler();
  
  app.prepare().then(() =&gt; {
      createServer(async (request, response) =&gt; {
          try{
              const parsedURL = parse(request.url, true);
              const { pathname, query } = parsedURL;
  
              switch(pathname){
                  case &quot;/a&quot;:
                  case &quot;/b&quot;:
                      await app.render(request, response, pathname, query);
                      break;
                  default:
                      await handle(request, response, parsedURL);
              }
          } catch(error){
              console.error(&quot;Error occurred.&quot;, request.url, error);
              response.statusCode = 500;
              response.end(&quot;Internal server error.&quot;);
          }
      }).listen(port, error =&gt; {
          if(error) throw error;
          console.log(`&gt; Ready on http://${hostname}:${port}`);
      });
  }).catch(error =&gt; {
      if(error) throw error;
  });
  </code></pre>
  <p><code>Failed to load next.config.js</code> was also output in my stderr file, despite <code>next.config.js</code> being provided.</p>
  <p>I've attached the current settings I have applied in my <strong>cPanel</strong>.</p>
  <p><em>Please note that I do not have root access to the terminal, and am restricted to the <code>next_main</code> environment when running any NPM scripts.</em></p>