Find PID of process that use a port on Windows

My service crash on startup with the classic :

java.rmi.server.ExportException: Listen failed on port: 9999

How can I find the process for killing it?


Just open a command shell and type : (saying your port is 123456)

netstat -a -n -o | find "123456"

You will see everything you need

The headers are :

 Proto  Local Address          Foreign Address        State           PID
 TCP    0.0.0.0:37             0.0.0.0:0              LISTENING       1111

Find PID of process that use a port on Windows (eg port:"9999")
netstat -aon | find "9999"

-a Displays all connections and listening ports.

-o Displays the owning process ID associated with each connection.

-n Displays addresses and port numbers in numerical form.

output:
TCP 0.0.0.0:9999 0.0.0.0:0 LISTENING 15776

Then Kill the process by PID taskkill /F /PID 15776

/F - Specifies to forcefully terminate the process(es).

Note: You may need an extra permission (run from admin) to kill some certain processes


After some fiddling with a script I came to this action. Copy and save it in a .bat file:

FOR /F "usebackq tokens=5" %%i IN (`netstat -aon ^| find "3306"`) DO taskkill /F /PID %%i

change 'find "3306"' in the port number which needs to be free. Then run the file as admin. It will kill all the processes running on this port

链接地址: http://www.djcxy.com/p/30282.html

上一篇: 如何在Windows中查找使用端口80的程序?

下一篇: 在Windows上查找使用端口的进程的PID