Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EADDRINUSE - still can't kill the Node Process

Tags:

node.js

I'm running terminal in webstorm. I try running node --harmony app.js and says my koa app.listen() is already running.

So I try to hunt and see what node processes are running via the command ps aux | grep node

I see a couple results:

myUserName         897   0.0  0.0  3083844    160 s000  T    11:15AM   0:00.32 node --harmony app.js
myUserName        1935   0.0  0.0  2441988    676 s000  S+    1:33PM   0:00.00 grep node

I try to kill 897 by doing a kill 897 or pkill 897 but it is still running. How do I get that to kill!!!??

like image 834
PositiveGuy Avatar asked Aug 12 '15 18:08

PositiveGuy


People also ask

How do I fix Eaddrinuse error?

EADDRINUSE means that the port number which listen() tries to bind the server to is already in use. So, in your case, there must be running a server on port 80 already. If you have another webserver running on this port you have to put node. js behind that server and proxy it through it.

How do I kill a NodeJS process?

To kill the main Node process, we just pass the pid of the main process. To see this in operation, replace the setTimeout function in our previous code example with this version that uses process. kill . This method also works in the REPL as well as in Node.

How do you stop a node process?

Method 1: Using ctrl+C key: When running a program of NodeJS in the console, you can close it with ctrl+C directly from the console with changing the code shown below: Method 2: Using process. exit() Function: This function tells Node. js to end the process which is running at the same time with an exit code.


2 Answers

kill -9 897

kill command sends a signal to the given process, but unless you use -9 which sends the SIGKILL signal, the process is allowed to attempt to kill itself.

like image 59
Samuel Avatar answered Oct 18 '22 14:10

Samuel


fuser -k 4060/tcp

where 4060 is the port on which your node server is running.

like image 44
kiran Sp Avatar answered Oct 18 '22 14:10

kiran Sp