Let´s say , we want to find out which program is using the port 80 and 443 in our computer. (The port number started with 80 or 443)

Enter the following at the prompt (cmd):

netstat -ano | findstr /r 0.0:80 && netstat -ano | findstr 0.0:443

In the last column, you can see the process ID. Here for example 4 for the port 80, and 14256 for the port 8000.

Now, let´s insert this ID in the following command :

tasklist /FI "PID eq 4" /FO TABLE

In this case, “System” uses port 80.

In this case (Process-ID = 14256), a docker image is using the port 8000.

Windows – Use Case

PS: the command to get the process-ID for a program using a specific port is :

//for port 80
netstat -ano | findstr /r 0.0:80

//for port XXX
netstat -ano | findstr /r 0.0:XXX

the task could be stopped/ended with :

// for port 80 in our case, because his PID is 4
taskkill /pid 4 /f

Linux – Use Case

To list any process listening to the port 8080:

lsof -i:8080

To kill any process listening to the port 8080:

kill -9 $(lsof -t -i:8080)

PS: -9 corresponds to the SIGKILL - terminate immediately/hard kill. It implies the process will be killed forcefully.

By Shabazz

Software Engineer, MCSD, Web developer & Angular specialist

Leave a Reply

Your email address will not be published. Required fields are marked *