Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

13 September 2026 · One command a day

How do I make PM2 apps start again after a reboot?

PM2 keeps your Node apps running, but on its own it forgets them when the server restarts. Running pm2 save writes down the current list of apps, and pm2 startup registers PM2 with systemd so it comes back on boot and restores that list. You reach for this once after setting up a new app, and again any time the list of apps changes.

The command

pm2 save && pm2 startup

pm2 save dumps the process list to ~/.pm2/dump.pm2. The && means the second command only runs if the first succeeds. pm2 startup detects the init system, which is systemd on Ubuntu 24.04, and prints a one-line command that creates the systemd unit. Unless you are root, it does not run that line for you. Run the whole thing as the user that owns the apps, not as root.

What you will see

[PM2] Saving PM2's process list...
[PM2] Successfully saved in /home/user/.pm2/dump.pm2
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u user --hp /home/user

The first two lines confirm the save and tell you where the dump file lives. The last line is the important one. Copy it exactly and run it. It needs sudo because it writes a unit file under /etc/systemd/system and enables it. When it finishes you will see a line saying the pm2-user service has been enabled. After that, a reboot brings PM2 up, and PM2 reads the dump file and starts everything in it.

When to use it

Watch out for

The most common mistake is stopping after the first run and assuming the job is done. pm2 startup only prints the command, and nothing is registered until you paste and run the sudo line it gives you. The second mistake is forgetting to save again after changing apps. The dump file is a snapshot, so an app started last week but never saved will not come back. Check the list with pm2 list and, if it looks right, run pm2 save. If the list is empty, PM2 refuses to overwrite the dump unless you add --force, which stops you wiping a good snapshot by accident.

Questions people ask

How do I test it without waiting for a reboot?

Run sudo systemctl status pm2-user, replacing user with your username, and check that it shows enabled. If you want proof, run sudo reboot at a quiet time and then pm2 list once you are back in.

How do I undo it?

Run pm2 unstartup. It prints a matching sudo command that removes the systemd unit. Your apps keep running until the next reboot, and you can still restart them by hand in the meantime.

Shared hosting never gives you a reboot to survive, because you never get a service manager of your own. On a VPS you decide what starts at boot. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

More daily notes: How do I restart one app with PM2 after a deploy? · How do I read the last 100 lines of a PM2 app's logs? · How do I see all my Node apps running under PM2?