Operating System - HP-UX
1753808 Members
7536 Online
108805 Solutions
New Discussion юеВ

Re: how to check which process is using a particular port# ?

 
SOLVED
Go to solution
Kenneth Leung_2
Frequent Advisor

how to check which process is using a particular port# ?

My application use a particular port# for connection. Now, it didn't work & I think the port is occupied by some zombie process. How can I find out the process to kill? Please help. Thanks a lot.
4 REPLIES 4
Michael Steele_2
Honored Contributor

Re: how to check which process is using a particular port# ?

Can you paste in your 'netstat -an' report? This will id server processes attached to a port. There are also sniffers like tcpdump and etheral and 'lsof' can provide a lot of information.
Support Fatherhood - Stop Family Law
Rajeev  Shukla
Honored Contributor
Solution

Re: how to check which process is using a particular port# ?

If your port number is listed in the /etc/services file then run
lsof|grep port_name(as show in /etc/services file) or just grep the port number
lsof |grep port_num
this will give you the application and the PID using that port
Yogeeraj_1
Honored Contributor

Re: how to check which process is using a particular port# ?

hi,

There exists the lsof utility which is available at:
ftp://vic.cc.purdue.edu/pub/tools/unix/lsof/

E.g. if you are getting a message that the port xx is in use. You then run netstat -a | grep to see if the port is in use.

You can determine which process by running: lsof -i TCP:. You can then decide whether to kill the process.

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Senthil Prabu.S_1
Trusted Contributor

Re: how to check which process is using a particular port# ?

Hi,
You can confirm whether that particular port is opened or not by netstat -na.

then, you need to run "lsof" command to find the process number of the service that is using the port.

Then kill it using kill -9 command.


Note:
If you dont have lsof utility installed on your machine. Download it from;
http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.77/


HTH,
Prabu.S
One man's "magic" is another man's engineering. "Supernatural" is a null word.