The solution for me was to restart pm2 using systemctl: systemctl reload-or-restart pm2-root
When I first set up my Ubuntu 18.04 server, I started pm2 start app.js to start my application. Then, when I tried to run pm2 startup + pm2 save to restart the application at boot time, this did not seem to work, since when starting systemctl list-units systemctl pm2 did not appear in the list of services. Even though the application has pm2 list ( pm2 list confirmed this). So I ran systemctl list-units -all , and pm2 was shown 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 via systemctl)
systemctl status pm2-root (to confirm that pm2 is now βactiveβ / βworkingβ)
Then I also launched systemctl enable pm2-root to start PM2 at startup (not sure if necessary)
And pm2 startup + pm2 save again (to start at boot)
OBS .: I used pm2-root in my commands since I started pm2 with the root , but you should replace it ( pm2-<USER> ) if necessary.
source share