WebGee DocsDocs
Development
Free migration + 30-day money-backSee how

Set up a Node.js application

Deploy a Node.js app in cPanel — creating the application, installing dependencies, and the restart that most changes require.

Run a Node.js application on your hosting account. Applies to shared, reseller and Premium hosting with the Node.js Selector available.

Before you begin

  • Your application files uploaded, outside public_html. cPanel serves the app through a proxy, so its source should not be directly downloadable.
  • A package.json in the application root.
  • The entry point filename — commonly app.js or server.js.

Create the application

  1. In cPanel, open Setup Node.js App under Software.

  2. Select Create Application.

  3. Fill in:

    FieldValue
    Node.js versionThe version your app needs
    Application modeProduction
    Application rootWhere your files are, e.g. nodeapp
    Application URLThe domain or subdomain to serve it
    Application startup fileYour entry point
  4. Select Create.

cPanel creates a virtual environment and starts the app.

Install dependencies

Use the Run NPM Install button on the application page. It reads package.json and installs into the application's own environment.

For anything more, work in the virtual environment — see Enter the virtual environment. Running npm from a plain SSH session uses the wrong Node and installs to the wrong place.

Environment variables

Add them on the application page rather than committing a .env file. Anything in your application root may be readable if the root is ever misconfigured, and values set here are held outside it.

Restart after changes

Node.js keeps your application in memory, so editing a file changes nothing until you restart. Unlike PHP, there is no per-request reload.

Use Restart on the application page after any code change. This is the most common reason a fix appears not to have worked.

Check it worked

Visit the application URL. If it does not respond, the application page shows the status and recent log output — start there.

Common problems

  • 502 Bad Gateway — the app is not running or crashed on startup. Check the log on the application page.
  • The port is wrong. Bind to process.env.PORT, not a hard-coded number. cPanel assigns the port.
  • Modules not found — dependencies were installed outside the virtual environment. Use Run NPM Install, or install from inside the environment.
  • It works then stops — the app may be exceeding account limits. See CloudLinux and LVE limits explained.

On this page

Hosted elsewhere?

Cloud Hosting

cPanel on NVMe storage, with LiteSpeed, free SSL and daily backups included.

See plansFree migration