Wednesday, November 24, 2010

How to know which port is blocked by which process on Windows?

Recently I was trying to use my apache server for my web development. However every time, I tried it showed me that port 80 is being used already. So I took a dig and found out the solution as follows.

C:\>netstat -aon | findstr 0.0:80
-a means list all active connections and their ports. -o means include their process IDs. -n means display the port numbers numerically.

I got this output.
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4504

It means that process 4504 is currently listening on port 80. So to start apache on this default port we need to kill this process, you can do it by Task Manager and find process by the id 4504 and kill that process.

You can also identify the process by using command line as follows.
C:\>tasklist | findstr 4504 

I found that skype is using the port 80.
Skype.exe  4504 Console 1 107,170K

So we need to kill the process as follows.
taskkill /F /PID 4504


Now we can start apache as usual. Even if we start skype again it will work, I think it choses some other random port this time.

Sphere: Related Content