Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to start node application since installing PM2

I have installed PM2 to keep my node application running. (https://github.com/Unitech/pm2)

It works great, however...

Since installing and running my app with it

pm2 start app.js pm2 stop app

I am no longer able to run my app using

node app.js

Instead I get the following error:

domain.js:66
    throw er;
          ^
Error: listen EADDRINUSE
    at errnoException (net.js:770:11)
    at Server._listen2 (net.js:910:14)
    at listen (net.js:932:10)
    at Server.listen (net.js:998:5)
    at Function.app.listen (/home/ssp/node_modules/express/lib/application.js:535:24)
    at Object.<anonymous> (/home/ssp/app.dev.js:22:5)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

This error usually happens when you try to run the same thing twice.

However app.js is not running. I have stopped it in PM2. And when I type

ps aux | grep node

To check if it is still there, it is not.

Uninstalling PM2 does not seem to fix this. Any ideas what is going on?

like image 381
user1031947 Avatar asked May 25 '26 15:05

user1031947


2 Answers

Overall this means that you have a process running on the same port, you can kill it using:

sudo kill $(sudo lsof -t -i:8080)

just replace 8080 with your server port

like image 96
Hazem Hagrass Avatar answered May 28 '26 04:05

Hazem Hagrass


If you get this problem do a :

pm2 kill

(it kills pm2 and the port is freed)

This bug is really strange and impact only v0.10.x node versions.

I recommend you to use the node v0.11.10

like image 28
Unitech Avatar answered May 28 '26 03:05

Unitech



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!