You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, this is a common PM2 + systemd + multiple user context issue.
When you install Node.js and PM2 as root, but run your apps and ecosystem setup as a non-root user, PM2 gets confused during pm2 startup because it mixes context between the root and non-root user environments.
Let’s fix it step-by-step so that your PM2 setup works reliably across reboots for the non-root user.
Step-by-Step Solution
Clean Existing PM2 Root Setup (Optional But Recommended) This avoids conflict between root and non-root PM2 environments.
Run this commands as root:
pm2 unstartup
pm2 kill
Switch to Your Non-root User
Let’s assume your non-root user is devuser. Switch if you're not already:
su - devuser
Or if you're logged in directly as devuser, skip this step.
Install PM2 Locally (Non-root)
Make sure pm2 is installed in this user’s environment.
npm install -g pm2
Run PM2 Startup for the Current User
This is crucial: Run pm2 startup as the non-root user.
I installed node and pm2(globally) as root user.
I setup all my project as non sudo user and setup ecosystem files for start applications using pm2
When i run pm2 startup. it provides command that command i run as root user. and then pm2 save.
After restart server, then pm2 is not able to restart all applications.
I checked pm-user.service is failing because pm2.pid file not found
I tried many times but PM2.PID is not creating So pm-nonuser.service is failing
Any solution??
The text was updated successfully, but these errors were encountered: