cPanel hosting on CloudLinux can run Node.js applications alongside PHP sites. The Setup Node.js App tool creates an isolated environment, connects it to a domain or path, and keeps the app running behind the web server through Phusion Passenger. You do not need to manage ports or a process manager yourself.
Before you start
- Your app's code with a
package.jsonand a start file such asapp.jsorserver.js. - The domain or subdomain for the app, already added in cPanel. A subdomain like
app.example.comkeeps it separate from your main site. See create a subdomain. - Optional: SSH access or Terminal for running npm commands.
Create the application
- Open cPanel → Software → Setup Node.js App and click Create Application.
- Node.js version: pick the version your app needs, preferably a current LTS release.
- Application mode:
Production(setsNODE_ENV=production). - Application root: a folder in your home directory for the code, e.g.
apps/myapp. Keep it outsidepublic_htmlso source files are not downloadable. - Application URL: choose the domain and optionally a path.
- Application startup file: e.g.
app.js. - Add Environment variables such as
DATABASE_URLor API keys. - Click Create. cPanel creates the folder with a test app and starts it.
Upload code and install packages
- Upload your files into the application root with File Manager, FTP or Git Version Control. Do not upload
node_modules. - Back in Setup Node.js App, click the pencil (edit) icon on the app. Click Run NPM Install. It installs dependencies from
package.json. - Or in Terminal, copy the command shown at the top of the app page (it looks like
source /home/user/nodevenv/apps/myapp/20/bin/activate && cd /home/user/apps/myapp), run it, then runnpm installor build steps such asnpm run build. - Click Restart.
How your app should listen
Passenger tells the app which port or socket to use. Use the standard environment variable instead of a fixed port:
const port = process.env.PORT || 3000;
app.listen(port);Do not start the app with node app.js & or PM2 on shared hosting; those processes are stopped and do not receive web traffic.
Warning: Node.js apps count toward your CloudLinux CPU and memory limits. Heavy build steps such as large Next.js builds are better done on your computer; upload the built output.
Logs and restarts
- After every code change, click Restart (or create
tmp/restart.txtin the app root). - Set Passenger log file in the app settings (e.g.
logs/passenger.log) to see startup errors andconsole.logoutput. - Stop App pauses it; Destroy removes the environment (not your files).
Troubleshooting
- "We're sorry, but something went wrong" / 503: the app crashed on start. Read the Passenger log; usually a missing package or wrong startup file.
- Cannot find module: run NPM Install again in the correct Node version.
- Static files 404: serve them with
express.staticor put them in the domain's public folder.
