Open nrcionline opened 2 years ago
I have the same issue in a Windows Server 2019
Restarting the computer solved this issue for me, this problem happened after I installed pm2-installer, removed it and then installed it again
Same here.
Same here..
for those who are experiencing the problem of the service stopped, go to Services > in the Log On tab, Set as local system account.
@Sandro-Sousa - Tried changing the service to local system account. Then the service was able to start. However after a reboot of the system, when I try to perform a pm2 list:
My understanding of the service is to provide a restart of pm2 after a reboot - currently I can't get this to work.
C:\Users\zenwa>pm2 list connect EPERM //./pipe/rpc.sock [PM2] Spawning PM2 daemon with pm2_home=C:\ProgramData\pm2\home node:events:505 throw er; // Unhandled 'error' event ^
Error: connect EPERM //./pipe/rpc.sock
at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
Emitted 'error' event on ReqSocket instance at:
at Socket.
After reboot, if I shut the service down, and then issue the Pm2 list command manually:
C:\Users\zenwa>pm2 list [PM2] Spawning PM2 daemon with pm2_home=C:\ProgramData\pm2\home [PM2] PM2 Successfully daemonized
Then PM2 starts successfully without the processes... [PM2][WARN] Current process list is not synchronized with saved list. App app differs. Type 'pm2 save' to synchronize.
At this point if I restart the service, the expected processes running under pm2 also come back. Possibly priv issue with the service? It is unable to start / deamonize pm2? after reboot...
you need to give admin permissions to access the folder where pm2 was installed globally, follow this tutorial:https://blog.cloudboost.io/nodejs-pm2-startup-on-windows-db0906328d75
if you already have the pm2 installer disregard the last two steps about the other tools
@Sandro-Sousa - just discovered the problem(FYI for NVM users): I am using nvm, and was using the default location, which is user specific. Changed the nvm install location to ProgramData\nvm ... also made sure all installation was done with admin. This change allowed the service to install normally (no endless "server state") AND start normally, and to come back after reboot. The last tidbit - unless you use an admin window to do the "pm2 list" after the reboot, you still get the above error.
When the PM2 service is stopped and you run the command line "pm2 start myapp", this starts the pm2 daemon. If you try to start the PM2 service while running the daemon the service would keep crashing. For Windows, you have to do the following steps in order: 1 - Restart machine. 2 - Run PM2 Windows Service through service console. 3 - Run command line "pm2 start myapp" 4 - Run command line "pm2 save"
This should start the service, register and run your app. Any further restarts should start your pm2 windows service as expected.
Adding the Local Service
username to the nodejs
folder > Properties > Security solved this for me. Local Service
is used on my PM2 Windows Services > Properties > Log On.
@Sandro-Sousa - just discovered the problem(FYI for NVM users): I am using nvm, and was using the default location, which is user specific. Changed the nvm install location to ProgramData\nvm ... also made sure all installation was done with admin. This change allowed the service to install normally (no endless "server state") AND start normally, and to come back after reboot. The last tidbit - unless you use an admin window to do the "pm2 list" after the reboot, you still get the above error.
thank you, this was the problem for me too, just reinstalled nvm to c:/program files and it worked fine 👍
After running this on windows server 2022 (including the configure options), all I get is: State is now: Stopped printing endlessly to the powershell window. I tried to manually start the PM2 process, but it won't start.