![]() |
|
Guide How to Host a Node.js App on CloudPanel with PM2 - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: CloudPanel (https://adminsforum.com/Forum-cloudpanel) +---- Forum: CloudPanel Guides & Tutorials (https://adminsforum.com/Forum-cloudpanel-guides-tutorials) +----- Forum: CloudPanel Node.js & Python Guides (https://adminsforum.com/Forum-cloudpanel-node-js-python-guides) +----- Thread: Guide How to Host a Node.js App on CloudPanel with PM2 (/Thread-guide-how-to-host-a-node-js-app-on-cloudpanel-with-pm2) |
How to Host a Node.js App on CloudPanel with PM2 - JAY - 10-19-2026 How to host a Node.js app on CloudPanel with PM2 CloudPanel can run Node.js apps such as Express APIs, Next.js, Nuxt, Ghost or Strapi. CloudPanel creates the site, a dedicated site user and an Nginx reverse proxy that forwards your domain to the port your app listens on. You run the app itself with PM2, a process manager that keeps it online and restarts it after a crash or reboot. What you need
Step 1: Create the Node.js site
Step 2: Log in as the site user Connect over SSH as the site user, not as root: Code: ssh site-user@YOUR_SERVER_IPCode: node -v
npm -vStep 3: Upload or clone your app Your site lives in Code: ~/htdocs/www.example.com/Code: cd ~/htdocs
rm -rf www.example.com
git clone https://github.com/your-name/your-app.git www.example.com
cd www.example.com
npm installCode: npm run buildCode: .envMake sure the app listens on the App Port you set in Step 1, for example: Code: const port = process.env.PORT || 3000;
app.listen(port, '127.0.0.1');Step 4: Start the app with PM2 Install PM2 for the site user and start the app: Code: npm install pm2@latest -g
pm2 start npm --name my-app -- start
pm2 saveCode: pm2 status
pm2 logs my-app
pm2 restart my-app
pm2 stop my-appStep 5: Start the app again after a reboot PM2 needs a cron job to bring your app back after the server restarts.
Step 6: Add free SSL Open the site in CloudPanel, go to SSL/TLS > Actions > New Let's Encrypt Certificate and create the certificate. Details: How to install free SSL in CloudPanel. Deploying updates Code: cd ~/htdocs/www.example.com
git pull
npm install
npm run build # only if your app has a build step
pm2 restart my-appTroubleshooting
Sources (checked October 2026): CloudPanel: Node.js deployment with PM2 ยท CloudPanel: Strapi Not sure which site type to choose? See What can you host on CloudPanel? |