How to Deploy a Node.js App with PM2 in cPanel
Running a Node.js application on cPanel hosting is very doable, but it helps to know how cPanel handles Node. There are two paths: cPanel's built-in "Setup Node.js App" tool (which uses Phusion Passenger to keep your app running), and PM2 (a process manager you run over SSH). This guide covers both and when each fits.
The standard route: Setup Node.js App
On most shared cPanel plans, the built-in tool is the recommended way, because it keeps your app alive for you. See setting up a Node.js application in cPanel for the full walk-through: you pick the Node version, the app root and the startup file, then start it. Passenger manages the process behind the scenes.
When PM2 comes in
PM2 is a popular process manager that keeps Node apps running, restarts them if they crash, and manages logs. It shines on a VPS or on plans that allow persistent background processes and give you SSH access. On strict shared hosting, long-running background processes may be limited, so check what your plan allows before relying on PM2.
Using PM2 over SSH
Where PM2 is supported, the basic flow is:
- Connect via SSH and go to your app directory.
- Install dependencies with
npm install. - Start the app under PM2, for example
pm2 start app.js. - Save the process list with
pm2 saveso it can be restored.
PM2 then keeps the app running and restarts it on failure.
Which should you choose?
On shared cPanel, prefer the built-in Node.js App tool โ it is designed for that environment. Choose PM2 when you have a VPS or a plan that explicitly supports persistent processes and you want its restart and monitoring features.
Frequently asked questions
My PM2 app stops after I close SSH.
On restrictive shared hosting, background processes can be terminated, which is why the Passenger-based tool exists. If you need PM2 to persist, you likely need a VPS or a plan that permits long-running processes.
Why does my app show "Cannot GET /"?
That usually means routing or the startup file is not set correctly. See fixing the Node.js "Cannot GET" error.
Which Node version should I use?
Use a current, supported Node.js version that matches your app's requirements. Both the cPanel tool and PM2 let you select the version; keep it updated for security and performance.
Was this article helpful?