User

Managing Apps with PM2

How to restart, stop, view logs, and delete Node.js apps managed by PM2 in Opterius Panel.

Last updated 1775606400

All Node.js apps in Opterius are managed by PM2. The panel provides a UI for common operations, and you can also use PM2 directly via SSH for anything more advanced.

App Controls

On the Node.js → app detail page:

Action What it does
Restart Stops and restarts the PM2 process. Use this after updating app files.
Stop Stops the process. The app will not restart until you manually start it again or restart the server.
Delete Removes the PM2 process entirely. Your app files are not deleted.

Viewing Logs

The detail page shows the last 100 lines of PM2 output logs (stdout + stderr combined). Refresh the page to see new output.

For streaming logs, use SSH:

pm2 logs myuser_myapp

To see only errors:

pm2 logs myuser_myapp --err

PM2 Process Names

The panel prefixes your app name with your account username:

App name: "api"
Account username: "johndoe"
PM2 process name: "johndoe_api"

Use this name when running PM2 commands directly:

pm2 restart johndoe_api
pm2 stop johndoe_api
pm2 logs johndoe_api --lines 200

Checking Status via SSH

pm2 list
pm2 show johndoe_api

Auto-Restart on Server Reboot

PM2 saves the process list automatically when you deploy or modify an app through the panel. All saved apps restart when the server boots.

If you've made changes directly via pm2 on the command line, save manually:

pm2 save

Common Issues

App keeps crashing (status: errored)

The process is crashing on startup. Check logs immediately after deploying:

pm2 logs johndoe_api --lines 50

Common causes:

  • Missing npm install — dependencies not installed
  • Syntax error in your code
  • Port already in use (choose a different port)
  • Missing environment variables

Port already in use

# Find what's using the port
ss -tlnp | grep :3000

If it's another PM2 app, they're sharing a port — each app must use a unique port.

App running but domain returns 502 Bad Gateway

Nginx is proxying to the port but nothing is listening there. Usually means:

  1. The app is stopped or crashed — check PM2 status
  2. The app is listening on a different port than configured — verify process.env.PORT is used

Next Steps