Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.57k stars 2.62k forks source link

Port address already in use error. #5889

Open htmlObserver opened 2 months ago

htmlObserver commented 2 months ago

I'm reading the documentation but can not find what requirements does an application need to meet in order to be managed by PM2 in cluster mode?

I'm trying to run 'gatsby serve' in cluster mode, but when attempting to 'reload' the application, I see errors in the logs related to the port already being in use:

Error: listen EADDRINUSE: address already in use 127.0.0.1:9000
    at Server.setupListenHandle [as _listen2] (node:net:1330:16)
    at listenInCluster (node:net:1378:12)
    at GetAddrInfoReqWrap.doListen (node:net:1516:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:73:8)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1357:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '127.0.0.1',
  port: 9000
}

The application doesn't start after reload command, but PM2 shows the status as "online," which is incorrect.

ifty64bit commented 2 months ago

I am also facing the same issue. I had to reload with id manually.

naegelin commented 1 month ago

There is a good example on how to use cluster mode here: https://medium.com/@manikmudholkar831995/clustering-and-pm2-multitasking-in-nodejs-c6b10249cfd4

Crane04 commented 1 month ago

I'm having this issue too