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

304
Vistas
Next.JS Cpanel Deployment Server.js not working properly

Im trying to deploy my website on cpanel. Im using node.js application with cpanel. see config:

enter image description here

but then i start my server it says "503 service unavailable".

enter image description here

when i try to edit my server.js file i see these weird errors.

enter image description here enter image description here enter image description here

server.js

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

const dev = process.env.NODE_ENV !== "production";
const hostname = process.env.HOSTNAME || "localhost";
const port = process.env.PORT || 3000;
// when using middleware `hostname` and `port` must be provided below
const app = next({ dev, hostname, port });
const handle = app.getRequestHandler();

app.prepare().then(() => {
  createServer(async function (req, res)  {
    try {
      // Be sure to pass `true` as the second argument to `url.parse`.
      // This tells it to parse the query portion of the URL.
      const parsedUrl = parse(req.url, true);
      const { pathname, query } = parsedUrl;
      await handle(req, res, parsedUrl);
    } catch (err) {
      console.error("Error occurred handling", req.url, err);
      res.statusCode = 500;
      res.end("internal server error");
    }
  }).listen(port, (err) => {
    if (err) throw err;
    console.log(`> Ready on http://${hostname}:${port}`);
  });
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

this might be better served as a comment and I apologise if it is but I'm unable to comment. I do however have something to contribute that may help move us towards an answer for this one.

I'm having a similar issue with my own application, what I have discovered is that however it's being interpreted by the server infrastructure what it wants is a semicolon after 'async'. This makes me wonder if perhaps in this kind of arena 'async' does something different to what we, the OP and I, are expecting it to, and how it typically operates on our local machines.

To Clarify, this block yields the same warning errors as OP mentions:

const register = async (req,res) => {
  const { username, email , password: Npassword, privilege} = req.body;
  if (!email || !Npassword || !username || !privilege)
    return res.json({ status: "error", error:"All Fields Required."});
  else {

However when the ';' is added after async those warning go away, it isn't a solution though as adding the semicolon there causes other warnings to pop up for the rest of the code:

const register = async; (req,res) => {
  const { username, email , password: Npassword, privilege} = req.body;
  if (!email || !Npassword || !username || !privilege) 
    return res.json({ status: "error", error:"All Fields Required."});
  else {

This is as much as I've been able to work out so far. As with OP my application runs perfectly fine on local machine and only has an issue when trying to deploy it on cpanel.

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