One day, I tried to start a new node js program, nevertheless, it show me the error message:
1 2 3 4 5 6 7 8 9 10 11 |
Error: listen EADDRINUSE :::12345 at Object.exports._errnoException (xxxxxxxxxxxxx) at exports._exceptionWithHostPort (xxxxxxxxxxxxx) at Server._listen2 (xxxxxxxxxxxxx) at listen (xxxxxxxxxxxxx) at Server.listen (xxxxxxxxxxxxx) at Object.<anonymous> (xxxxxxxxxxxxx) at Module._compile (xxxxxxxxxxxxx) at Object.Module._extensions..js (xxxxxxxxxxxxx) at Module.load (xxxxxxxxxxxxx) at tryModuleLoad (xxxxxxxxxxxxx) |
So I just go to find out which program is using the same port:
1 |
netstat -plunt |grep :12345 |
And go to check that is there any node js program is executing already:
1 |
ps -ef | grep node |
Bingo, there is some node js is performing, also one program that occupies the 12345 port.
Then I just kill the program and start my new program:
1 2 |
kill [id] node index.js |
However, I tried much time to kill the program, but It just rebuilds again and again. That I using the
1 |
ps -ef | grep node |
and find out that the user who is using “PM2” to start the program and added the watch function that why ‘when the program down, it will start it again automatically’. So I have to find the user to stop it. because the program is abandon already.
Okay, then I try to start the program again and It works.