We stumbled upon a very strange problem while running any pm2 command. While running
pm2 list
we got this result inside console
[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
but our pm2 log gives us more info about the error:
PM2] Spawning PM2 daemon with pm2_home=/root/.pm2 2023-11-15T14:06:46: PM2 log: =============================================================================== 2023-11-15T14:06:46: PM2 log: --- New PM2 Daemon started ---------------------------------------------------- 2023-11-15T14:06:46: PM2 log: Time : Wed Nov 15 2023 14:06:46 GMT+0000 (Coordinated Universal Time) 2023-11-15T14:06:46: PM2 log: PM2 version : 5.3.0 2023-11-15T14:06:46: PM2 log: Node.js version : 16.20.2 2023-11-15T14:06:46: PM2 log: Current arch : x64 2023-11-15T14:06:46: PM2 log: PM2 home
: /root/.pm2 2023-11-15T14:06:46: PM2 log: PM2 PID file : /root/.pm2/pm2.pid 2023-11-15T14:06:46: PM2 log: RPC socket file
: /root/.pm2/rpc.sock 2023-11-15T14:06:46: PM2 log: BUS socket file
: /root/.pm2/pub.sock 2023-11-15T14:06:46: PM2 log: Application log path : /root/.pm2/logs 2023-11-15T14:06:46: PM2 log: Worker Interval
: 30000 2023-11-15T14:06:46: PM2 log: Process dump file : /root/.pm2/dump.pm2 2023-11-15T14:06:46: PM2 log: Concurrent actions
: 2 2023-11-15T14:06:46: PM2 log: SIGTERM timeout : 1600 2023-11-15T14:06:46: PM2 log: =============================================================================== [PM2] PM2 Successfully daemonized 2023-11-15T14:06:46: PM2 log: =============================================================================== 2023-11-15T14:06:46: PM2 log: --- PM2 global error caught --------------------------------------------------- 2023-11-15T14:06:46: PM2 log: Time : Wed Nov 15 2023 14:06:46 GMT+0000 (Coordinated Universal Time) 2023-11-15T14:06:46: PM2 error: Listen method has been called more than once without closing. 2023-11-15T14:06:46: PM2 error: Error [ERR_SERVER_ALREADY_LISTEN]: Listen method has been called more than once without closing. at new NodeError (node:internal/errors:387:5) at Server.listen (node:net:1550:11) at Server. (/usr/local/lib/node_modules/pm2/node_modules/pm2-axon/lib/sockets/sock.js:408:21) at Server.emit (node:events:513:28) at Server.emit (node:domain:489:12) at Pipe.onconnection (node:net:1696:10) at Pipe.callbackTrampoline (node:internal/async_hooks:130:17) 2023-11-15T14:06:46: PM2 log: =============================================================================== 2023-11-15T14:06:46: PM2 error: [PM2] Resurrecting PM2 Be sure to have the latest version by doingnpm install pm2@latest -g
before doing this procedure. node:net:1550 throw new ERR_SERVER_ALREADY_LISTEN(); ^Error [ERR_SERVER_ALREADY_LISTEN]: Listen method has been called more than once without closing. at new NodeError (node:internal/errors:387:5) at Server.listen (node:net:1550:11) at Server. (/usr/local/lib/node_modules/pm2/node_modules/pm2-axon/lib/sockets/sock.js:408:21) at Server.emit (node:events:513:28) at Server.emit (node:domain:489:12) at Pipe.onconnection (node:net:1696:10) at Pipe.callbackTrampoline (node:internal/async_hooks:130:17) { code: 'ERR_SERVER_ALREADY_LISTEN' }
in the background pm2 runs dozen of this process
node /usr/local/bin/pm2 update
which result in running server out of memory