Tuesday, 1 August 2017

How to kill a process running on particular port in windows?

If you use restify in node js you might have encountered the following error.

in the VS Code terminal, if you run the node command and then close the terminal and try to run the app in another terminal you definitely will get an error saying the port is still open like following.
in my case, I'm using bot framework and I'm using the default port which is 3978. Yours can be a different port



Error: listen EADDRINUSE :::3978
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at Server._listen2 (net.js:1258:14)
    at listen (net.js:1294:10)
    at Server.listen (net.js:1390:5)
    at Server.listen
    at App.run
    at Object.<anonymous>
    at Module._compile
    at Object.Module._extensions..js

The easiest way is to find the process id of the app, which is using the port by running following command line

netstat -ano |find /i "3978"

you will get something similar to following

 TCP    0.0.0.0:3978           0.0.0.0:0              LISTENING       2208
 TCP    [::]:3978                 [::]:0                    LISTENING       2208

after finding the process Id which in my case is 2208, you can run the following command

Taskkill /PID 2208 /F

If things go successfully you will get the following message
SUCCESS: The process with PID 2208 has been terminated.





Post a Comment