Tuesday, February 11, 2014

How do I know which process is using which port

Recently I have encountered with a weird problem (Website is not being started) and there is an application error which is totally unclear to me. Just like any other person I have googled the error :P The interesting thing I have noticed is "Your website is not being started as there is some other application which is using port 80 (which is my website's port). ".

The explanation seems very clear but that won't solve my problem right :D
Now the task in my hand is " I have to find out the process which uses the port 80, which is very new to me." Finally I am able to achieve it and below was my approach.

Finding out which application is using port 80, One can find out using the command prompt what is the application's PID which is using port 80. A sample one is shown below





The results will show what is/are the application(s) which are using this port. In my example I searched the application which is using port "1521" and the screen shot shows the result. The command used to fetch the result is shown below

netstat -na|find "1521"

Give your port number instead of 1521. Now from the results you can figure out certain things, the third column will give the thing which you need. One of the result from the above is 

 TCP    192.168.10.127:1521    192.168.10.127:53710   ESTABLISHED

The highlighted column will convey everything, here in this case it is 192.168.10.127:53710

This 53710 is the PID of the process which is using this port.

From this I could able to find out the PID of the application which is using the port "80". Now I have to find out the process which is using this PID, this can be achieved by using task manager


From this I could understand that the application PID which I am searching is used by some other application which is "Skype", which is when I have realized that "Yes this problem occurred when I have installed skype". Normally I did not get any hint of how come skype will be the reason for this problem. What I did was just killed the skype application and then started the IIS. 

No wonder IT WORKED.










----------------------------------------------------------------------------------------------------
[Updated from here on 19th Nov 2014]
There is a software "ProcessExplorer" which is a freeware and which identifies the process with a specific PID. After you identifying the PID using the above process, run the procexp.exe and locate the process bearing this PID which you have recorded.



Now my next task is to try and identify what is the process which is bearing the PID : 4340 and from the above image I could see that it is a java.exe and I know that each cordys soap container will create a new java.exe and so I try to debug by looking into CMC (Cordys Management Console) which is an application which shows the container status and information about each container. Now try and locate the container which has the same PID as the one which you wanted (4340).

  
Its found out to be as LDAP. By this one could understand that LDAP is the java.exe which is running on a port which you are checking.

----------------------------------------------------------------------------------------------------------
Dated : 08-07-2015

You can find the PID directly from a port using below command,

netstat -ano|find "1521"

I wanted to kill this process and I could not find it in task manager. I killed it from command prompt using below command, 

taskkill/f /PID /7076

---------------------------------------------------------------------------------------------------------

No comments:

Post a Comment