![]() |
|
Guide Node.js App on CloudPanel Shows 502 or Keeps Restarting: PM2 Fixes - 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 Node.js App on CloudPanel Shows 502 or Keeps Restarting: PM2 Fixes (/Thread-guide-node-js-app-on-cloudpanel-shows-502-or-keeps-restarting-pm2-fixes) |
Node.js App on CloudPanel Shows 502 or Keeps Restarting: PM2 Fixes - JAY - 10-23-2026 Node.js app on CloudPanel shows 502 or keeps restarting: PM2 fixes Your Node.js site in CloudPanel shows 502 Bad Gateway, or it works for a while and then dies, or it's gone after every server reboot. For a Node.js site, CloudPanel's Nginx simply forwards visitors to your app on a local port. A 502 means Nginx knocked on that port and nobody answered. This guide shows how to find out why. Setting up a new app? See How to host a Node.js app on CloudPanel with PM2. Step 1: Compare the ports When you created the Node.js site, you entered an App Port (for example 3000). Nginx sends traffic to Code: 127.0.0.1:3000Code: ss -tlnp | grep node
Step 2: Is PM2 running the app? Log in as the site user (PM2 is per user, so root's PM2 list is a different one): Code: pm2 list
Step 3: Read the app's error log Code: pm2 logs --lines 50
Code: pm2 restart allStep 4: App gone after a reboot PM2 doesn't remember your apps across reboots unless you tell it to. As the site user, after the app runs correctly: Code: pm2 save
pm2 startupCode: pm2 startupCode: sudo env PATH=...Step 5: App dies under load or every few hours Often the server runs out of memory and Linux kills the biggest process. Check: Code: free -h
dmesg -T | grep -i 'killed process' | tailCode: pm2 start npm --name myapp --max-memory-restart 400M -- startQuick checklist
Sources: PM2: quick start · PM2: startup script · CloudPanel: site:add:nodejs More CloudPanel troubleshooting
Applies to CloudPanel v2 on Ubuntu and Debian, October 2026. Replace 3000 with your site's App Port. |