lsof not showing what port a proc is listening on

Posted by ericslaw on Server Fault See other posts from Server Fault or by ericslaw
Published on 2010-03-17T19:54:19Z Indexed on 2010/03/17 20:01 UTC
Read the original article Hit count: 301

Filed under:
|
|
|
|

I have many processes on a box listening on several ports.
I am trying to map ports to pids.
The problem is that lsof is not telling me what ports belong to which process.

Given an apache listening on port 80, I can see it listening via netstat:
user@host% netstat -an|grep LISTEN|grep 80
*.80 *.* 0 0 49152 0 LISTEN

But when I try to map port 80 to a pid I get nothing:
user@host% lsof -iTCP:80 -t

When I try seeing what sockets that specific pid is using I get:
user@host% lsof -lnP -p31 -a -i
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
libhttpd. 31 0 15u IPv4 0x6002d970b80 0t0 TCP *:65535 (LISTEN)

Notice the *:65535 in the NAME column.

Does anyone know why lsof is not reporting the port in use?

I am running as root. I am using a mix of lsof and os versions:
lsof v4.77 on Solaris10 sparc
lsof v4.72 on Redhat4.2
etc

I know that linux solutions can use "netstat -p",
so I guess I'm only looking for why solaris isn't working, but I find lsof is frequently silent and not showing me expected data.

© Server Fault or respective owner

Related posts about unix

Related posts about lsof