Which operating system are you using? The answer may differ depending on the type of the operating system, including different distributions.
For example, on some Linux distributions I'd rather use ss -nltp
.
Example:
$ ss -nltp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 10 127.0.0.1:25 *:*
LISTEN 0 128 :::111 :::*
LISTEN 0 50 :::8080 :::*
LISTEN 0 128 :::22 :::*
Explained:
-n, --numeric don't resolve service names
(google.com --> 1.2.3.4)
-l, --listening display listening sockets
(just the ports you're listening at)
-p, --processes show process using socket
(include sub processes locking sockets)
-t, --tcp display only TCP sockets
A more general command would be netstat
.
Example: $ netstat -nl
Please check the manual of ss
for more information.
Edit: Since you said you were using Windows, you can use this to list all the relevant processes (-n == numeric, -a == all, -o == show process id, -p TCP == show TCP only):
netstat -nao -p TCP
Last column would be the process ID, you can use taskkill
to kill the process:
taskkill /F /PID <PID>
Where /F
says forcefully kill and /PID
indicates the next value is the process ID.