pm2
pm2 copied to clipboard
PM2 don't restart automaticaly after system reboot
Hey there!
I'm really embarrassed with this problem: pm2 don't restart after a system crash (or just a simple system reboot).
I had read the documentation and maked the stratup strategy like that:
- Add my NodeJS conf into ecosystem file
- Start this ecosystem file with pm2
- Generate a startup script with
pm2 startup - Copy/paste the command to add the script on systemd
- Save the state with
pm2 save - Try a reboot and see that pm2 is not up after reboot
If i do a systemctl status , i see the error bellow:

But, if i do manually pm2 resurrect, pm2 start and my app is alive. .
Thank's a lot for your help!
Facing the same issue
Facing the same issue...

Any updates ?
No 😨
I have to do a pm2 resurrect on each reboot. Sure, I can make a script that runs pm2 reboot on each boot, but thats a bandaid. What broke with PM2? This may have coincided with a node version change (uninstalling one version to install another)
After hours and hours ... that's what worked for us (ubuntu +20): once you have managed your node app with pm2 (using pm2 start and checking with pm2 list and so on) the key command here is: pm2 startup This command will give you a Startup Script which you need to copy/paste wherther using a sudo user or root. The script looks like this: sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u youruser --hp /home/youruserhome
And voila! your config is persistent now
Then verify with a reboot and reconnect and check your process running with a pm2 list
Hope it helps!
After hours and hours ... that's what worked for us (ubuntu +20): once you have managed your node app with pm2 (using pm2 start and checking with pm2 list and so on) the key command here is: pm2 startup This command will give you a Startup Script which you need to copy/paste wherther using a sudo user or root. The script looks like this: sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u youruser --hp /home/youruserhome
And voila! your config is persistent now
Then verify with a reboot and reconnect and check your process running with a pm2 list
Hope it helps!
THANK YOU.
Following the prompts from pm2 startup worked for me.
No change, ran command via sudo and directly as root.
Got it !
for whatever reason the command printed was missing my user.
# given DOES NOT WORK
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 unstartup systemd -u --hp /home/USERNAME
# Actual
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 unstartup systemd -u USERNAME --hp /home/USERNAME
I noticed the missing user -u argument was causing invalid startup script.