Operating System - HP-UX
1756122 Members
3014 Online
108841 Solutions
New Discussion юеВ

Re: Determine who is binding to a port

 
SOLVED
Go to solution
Joel Shank
Valued Contributor

Determine who is binding to a port

Does anyone know if there is a way to determine
what application/program has bound to a port?
I have an app that is supposed to bind to port 3000, but when it tries it gets rejected because the port is already open by another app. Is there a way to find out who that other app is?

Thanks much,
jls
13 REPLIES 13
Mel Burslan
Honored Contributor
Solution

Re: Determine who is binding to a port

you should use lsof as follows:

lsof -i tcp | grep $Port_Number

if you do not have lsof, you can obtain it from:

http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.76/

hope this helps
________________________________
UNIX because I majored in cryptology...
Helen French
Honored Contributor

Re: Determine who is binding to a port

'lsof' would be the best tool to use for this purpose. You can also try 'rpcinfo -p' and 'netstat -an' commands to check the status of programs.
Life is a promise, fulfill it!
Raj D.
Honored Contributor

Re: Determine who is binding to a port

Hi Joel ,

Its very easy using lsof,

# cd /usr/local/bin
# ./lsof -i:3000

It will list all those who have bind to that port.

If you do not have lsof get it from:
http://hpux.cs.utah.edu

Example:

# ./lsof -i:23
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
inetd 1158 root 6u inet 0x4b39fc68 0t0 TCP *:telnet (LISTEN)
telnetd 20935 root 0u inet 0x4b393268 0t0 TCP sapsrv12:telnet->sapsrv12:62951 (ESTABLISHED)
telnetd 20935 root 1u inet 0x4b393268 0t0 TCP sapsrv12:telnet->sapsrv12:62951 (ESTABLISHED)
-----------------------------


Enjoy ..
Cheers,
Raj.

" If u think u can , If u think u cannot , - You are always Right . "
Joel Shank
Valued Contributor

Re: Determine who is binding to a port

I downloaded lsof and installed it, but when I run it I get a core dump (segment violation). Is there something else I have to do? I am running HPUX 11i 64bit (which is what the lsof I installed was supposed to be).

Thanks,
jls
Raj D.
Honored Contributor

Re: Determine who is binding to a port

Hi Joel ,

This happens when instllation is not proper, or you have not downloaded the wrong file , that is of not correct version,. Have you downloaded for 11.11 and PA-RISC version.


hth,
Raj

" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Determine who is binding to a port

Hi Joel ,

Any way , you can download the binary directly from here , and gunzip it and can be run ,


This is for hp-ux 11.11

http://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/binaries/hpux/B.11.11/lsof_4.7
6.gz

After downloading and transfering to server do:

# gunzip lsof_4.76.gz
# mv lsof_4.76 lsof
# chmod +x lsof

# ./lsof -i:3000


Enjoy,
Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Mel Burslan
Honored Contributor

Re: Determine who is binding to a port

make sure of your processor type and download the correct version of lsof. There are two versions on the link I gave on the first response. One is for ver 11.11 running on PA-RISC and other one is for 11.22 or 11.23 on Itanium. (If you are running 11.23 on PA-RISC, I think the only optionyou have is to recompile the binary from source code)

Make sure you downloaded the right version. If not do it again. If you believe, you have downloaded the right one, let us know your machine model, os revision etc.. the vital statistics
________________________________
UNIX because I majored in cryptology...
Raj D.
Honored Contributor

Re: Determine who is binding to a port

Joel ,

Seems the above link may not work:

Try this for download:

http://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/binaries/hpux/

Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Joel Shank
Valued Contributor

Re: Determine who is binding to a port

Raj, your link worked (just had to add the remaining few characters) and the lsof command now works too!

Thanks so much for all of you for your assistance.
jls