Configure PM2 Startup for Automatic Reboot

How to use 'pm2 startup' to ensure PM2 processes start automatically after a system reboot.
March 24, 2026

Configure PM2 Startup for Automatic Reboot

Using PM2 allows for stable management of Node processes, but these processes terminate when the system reboots.
By utilizing the pm2 startup command, you can configure the server to automatically restore previously running processes when it restarts.

1. Generate Startup Script

First, run the command to generate a startup script suitable for your current system environment.
Generate PM2 startup command
sh

2. Execute the Generated Command

Copy the last line of the output (starting with sudo env ...), paste it into the terminal, and execute it.
This step registers PM2 as a service in the system's systemd or init.d.
Execute the generated PM2 startup command
sh

3. Save Process List

You must save the list of currently running processes so they can be restored exactly as they were upon reboot.
This is the most important step, so it must be performed while all processes are running.
Save current PM2 process list
sh

4. Verification

Once the configuration is complete, you can verify that the processes start up normally after a system reboot without any additional manual work.
Check PM2 status after reboot
sh
Now, even if the server shuts down unexpectedly or reboots for regular maintenance, services will automatically recover without interruption.
Jooojub
System S/W engineer
Explore Tags
Series
    Recent Post
    © 2026. jooojub. All right reserved.