0

Trying to setup pm2 to restart the next.js node app on reboot of the server according to Windows: Auto start PM2 and node apps

on reboot and running pm2 ls I get : anyone have any ideas?

C:\Users\snoruzi>pm2 ls
connect EPERM //./pipe/rpc.sock
[PM2] Spawning PM2 daemon with pm2_home=C:\Users\snoruzi\.pm2
node:events:368
      throw er; // Unhandled 'error' event
      ^
Error: connect EPERM //./pipe/rpc.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)
Emitted 'error' event on ReqSocket instance at:
    at Socket.<anonymous> (C:\Users\snoruzi\AppData\Roaming\npm\node_modules\pm2\node_modules\pm2-axon\lib\sockets\sock.js:201:49)
    at Socket.emit (node:events:390:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'connect',
  address: '//./pipe/rpc.sock'
}

The app is started by running yarn pm2 which runs the file pm2.json - which tells pm2 where the entry point of the node application is

{
    "apps": [
        {
            "name": "centra-website",
            "script": "node_modules/next/dist/bin/next",
            "args": "start",
            "cwd": "./",
            "instances": "max",
            "exec_mode": "cluster"
        }
    ]
}

Service seems to be added fine and the pathing to executable looks correct

enter image description here

TigerCode
  • 315
  • 3
  • 15
  • 1
    Please where able to resolve this I'm stuck with same error running pm2 with nextjs – Eidris Aug 13 '22 at 17:31
  • https://stackoverflow.com/questions/48404492/pm2-eperm-operation-not-permitted-on-call-initgroups follow this, log the error and make sure you can see why exactly its throwing it. make sure you have permissions set up to run yarn pm2 properly with admin – TigerCode Aug 15 '22 at 17:11

1 Answers1

0

Try making sure that your command prompt is run as administrator. This fixed the issue for me.

Scorpv69
  • 176
  • 2
  • 4