PM2 process not restarting after crash — how to fix
TL;DR
Troubleshooting guide for PM2 processes that crash and fail to restart automatically.
Key facts
- Topic
- Production error triage
- Stack
- Node.js / PM2 / Linux
TL;DR
When a PM2-managed Node.js process crashes but fails to restart, your application goes down with no automatic recovery. This typically manifests as PM2 showing the process in errored status with a high restart count, or the process disappearing from the PM2 list entirely.
Common causes
- The application crashes immediately on startup (bad config, missing env vars), causing PM2 to hit its max restart limit
- The PM2 daemon itself crashed or was killed (OOM, server reboot without a startup hook)
- File permission changes after a deploy prevent the app from reading configs or writing logs
- Port conflicts — another process grabbed the port during the restart window
Immediate fix
Check PM2 status and recent logs:
pm2 status
pm2 logs --lines 100
pm2 describe app-name
If the process is in errored state, reset the restart counter and restart:
pm2 reset app-name
pm2 restart app-name
If PM2 itself is dead, resurrect saved processes:
pm2 resurrect
Prevention
Ensure PM2 persists across reboots:
pm2 startup systemd
pm2 save
Set sensible restart limits in your ecosystem file:
module.exports = {
apps: [{
name: 'app',
script: 'app.js',
max_restarts: 15,
min_uptime: '10s',
restart_delay: 5000,
exp_backoff_restart_delay: 100,
}],
};
The min_uptime value tells PM2 how long a process should run before it considers the start successful. If the process dies before this threshold repeatedly, PM2 stops restarting it.
Where Reflex helps
Reflex tracks your PM2 process states and detects when a process enters the errored state or stops restarting. It can execute automated recovery — clearing stale PID files, resetting restart counters, and restarting the process — then verify the application responds to health checks. See How it works.