In lsof command under Ubuntu/Debian, I'm seeing a lot of lines like below:
PROGRAM 829 root 140u sock 0,8 0t0 244182 protocol: TCP
What are these lines?
Can they be results of failed TCP connection attempts?
lsof
In lsof command under Ubuntu/Debian, I'm seeing a lot of lines like below:
PROGRAM 829 root 140u sock 0,8 0t0 244182 protocol: TCP
What are these lines?
Can they be results of failed TCP connection attempts?
Best Answer
This line is displayed when
lsof
cannot find additional informations on the TCP socket: it knows it's a TCP socket but not more.There are two reasons I can think of:
Unlikely: the socket is still not listening nor connecting: ie a server or client used for example
socket(AF_INET, SOCK_STREAM, 0)
to create a TCP socket but didn't call yetlisten(2)
orconnect(2)
. This could be caused by lack of resources or a buggy software.Most likely today: the process seen by
lsof
runs in an other network namespace, typically in a container (Docker, LXC, LXD ...) and thuslsof
doesn't have access to the relevant information and doesn't display it.You should then run
lsof
from the same network namespace as the process. Thelsns
andnsenter
commands can greatly help for this. For your case this would then probably work:In normal cases
lsof
would displayIPv4
orIPv6
instead ofsock
and would have additional informations, like listening port or addresses involved. Even a connection still ongoing would be displayed with the addresses involved and for exampleSYN_SENT
.