pm2 Startup not starting up on Ubuntu

The solution for me was restarting pm2 with systemctl: systemctl reload-or-restart pm2-root

When I setup my Ubuntu 18.04 server on the first time, I ran pm2 start app.js to start my app. Then when I tried to run pm2 startup + pm2 save to restart the app on boot, this seemed to be not working, as by running systemctl list-units, pm2 didn’t show up in the services list. Even though the app was running (pm2 list confirmed that). So I ran systemctl list-units -all, and pm2 showed as “inactive” and “dead”.

So I did:

  • systemctl status pm2-root (just to confirm that it was "inactive"/"dead")

  • systemctl reload-or-restart pm2-root (to restart pm2 through systemctl)

  • systemctl status pm2-root (to confirm that pm2 now was “active”/“running”)

  • Then I also ran systemctl enable pm2-root, to enable PM2 to run on startup (not sure if necessary)

  • And pm2 startup + pm2 save again (for the start on boot)

OBS.: I used pm2-root in my commands, as I was running pm2 with root user, but you should replace for your user (pm2-<USER>), if needed.


You have to save your node app using

 pm2 start [app_name]
 pm2 save

Then do:

 pm2 startup [operation system]

This will create a dump.pm2 file that pm2 needs to run your app on reboot.

Operation system:

  • systemd: Ubuntu >= 16, CentOS >= 7, Arch, Debian >= 7
  • upstart: Ubuntu <= 14
  • launchd: Darwin, MacOSx
  • openrc: Gentoo Linux, Arch Linux
  • rcd: FreeBSD
  • systemv: Centos 6, Amazon Linux

Tags:

Ubuntu

Pm2