Monday 16 July 2018

pm2 cluster mode with express EADDRINUSE

I'm trying to run a node app using pm2. The app by default runs on port 2345, I've changed the config to so it runs in cluster mode and 'instances' is set to max which at the moment only launches 2 instances. As soon as I start the app and both instances of the app launch, one keeps restarting until it does so 15 times at which point it errors out. Looking at the log it complains that"Error: listen EADDRINUSE :::2345"How can I run the app in cluster mode w/o it crashing? Everything I found online points to running the app on a single port and the cluster manages everything. I'd rather have this scale up/down depending on the server resources rather than having to manually edit the config and run X number of apps in fork mode all on different ports.

Submitted July 16, 2018 at 12:34PM by cinek2

No comments:

Post a Comment