Spring Fresh Sale! - Up To 67% OFF BDIX Hosting + Free Domain
Node.js

How to Set the Startup File and Application Root in cPanel Node.js

Two settings decide whether your Node.js app starts at all in cPanel: the application root (where your files live) and the startup file (the entry point cPanel runs). Getting these right is the most common fix for an app that will not launch.

Application root

This is the folder, relative to your home directory, containing your app's files — including package.json and your startup file. For example myapp means /home/username/myapp. Upload your project there before creating the app.

Application URL

This sets where the app is served — a domain or subdomain. For putting it on a subdomain specifically, see routing a Node.js app to a subdomain.

Startup file

This is your app's entry point — the file cPanel runs to start it, such as app.js, server.js or index.js. It must exist in your application root and must be the file that actually starts your server.

Setting them up

  1. Open Setup Node.js App in cPanel and create or edit your app.
  2. Set the Application root to your project folder.
  3. Set the Application startup file to your entry file.
  4. Save and restart.

A key point about the port

On cPanel, Passenger runs your app and provides the port via an environment variable — your app should listen on process.env.PORT, not a hard-coded port. This is a frequent cause of failures; see what Phusion Passenger is and fixing "application failed to start".

Frequently asked questions

What should my startup file be?

Whatever file starts your server — commonly app.js or server.js. It must be in your application root and must be the actual entry point that launches the app.

My app root has files but the app won't start.

Check that the startup file name matches exactly, that package.json is present, and that your app listens on process.env.PORT. A mismatch in any of these is the usual cause.

Can I change the application root later?

Yes, by editing the app, but make sure your files actually live in the new root. Moving the root without moving the files will stop the app running.

Was this article helpful?