Contents

PM2 services missing after reboot? Restore every process from the .pm2 folder (full guide)

PM2 services disappear after reboot? How to restore all processes from .pm2 (complete guide)

When deploying Node.js apps on a server, many people rely on PM2 for process management. But after a server reboot, they run into:

pm2 list
→ empty, no services

Yet the .pm2/ folder is still there, which means your previous process info exists. So why do PM2 services vanish? How do you bring them back?

This guide explains why PM2 processes go missing and gives three end-to-end recovery options.


🧩 Why do PM2 processes vanish after reboot?

There are three common causes:


1. You never ran pm2 save (most common)

PM2 does not auto-save the running app list.

You must run:

pm2 save

It generates:

~/.pm2/dump.pm2

That file restores processes after reboot.

If you skip it, PM2 will start after reboot but the process list will be empty.


2. Startup is not configured

You need to run:

pm2 startup

And execute the systemctl command that PM2 prints:

Example:

sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u ubuntu --hp /home/ubuntu

If you skip this, PM2 will not read dump.pm2 at boot and will not restore processes.


3. Using the wrong user for pm2

PM2 processes are separated by user:

UserPM2 data directory
root/root/.pm2/
ubuntu / admin/home/ubuntu/.pm2/
wenhao/home/wenhao/.pm2/

If you:

  • started services as ubuntu
  • after reboot, check with root

You get:

pm2 list → empty

But the .pm2 folder actually lives under the original user.


🟢 Scenario 1: dump.pm2 exists → one-command restore

Check the file:

ls ~/.pm2/dump.pm2

If it exists:

🔥 Run the restore:

pm2 resurrect

Then:

pm2 list

All services return, including:

✔ names
✔ start params
✔ env vars
✔ restart strategy

This is the cleanest and most complete way.


🟠 Scenario 2: No dump.pm2, but you have an ecosystem file

If your project folder includes:

ecosystem.config.js

Recovery is easy:

pm2 start ecosystem.config.js
pm2 save

All services are restored based on the ecosystem definition.


🔵 Scenario 3: No dump.pm2 and no ecosystem → recover from PM2 logs

Even without a dump file, PM2 logs record the commands you previously ran.

Search history:

grep "pm2 start" ~/.pm2/*log

Sample output:

pm2 start app.js --name api
pm2 start worker.js --name job-worker

Then re-run:

pm2 start app.js --name api
pm2 start worker.js --name job-worker
pm2 save

This recreates the exact process setup.


🧪 After recovery, enable auto-start (critical)

Otherwise, you’ll lose processes again on the next reboot.

Run:

pm2 startup

PM2 prints something like:

sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u ubuntu --hp /home/ubuntu

Copy and execute that line.

Then save the current list:

pm2 save

🧱 Best practices to avoid losing PM2 processes

Here is the recommended combo:

1. Save immediately after starting services

pm2 save

2. Enable boot startup

pm2 startup

3. Run the PM2-generated systemctl command

(This is the step most people forget.)

4. Back up the .pm2 folder regularly

~/.pm2/dump.pm2
~/.pm2/logs/

🧭 Summary

ScenarioRecovery approach
dump.pm2 existspm2 resurrect
ecosystem.config.js existspm2 start ecosystem.config.js
Neither existsRebuild from logs and pm2 save

In every case, your processes can be restored.


📩 If you share the following, I can auto-recover for you:

whoami
ls -l ~/.pm2
cat ~/.pm2/dump.pm2