Why ss show a port is in use but lsof doesn't?
1
vote
1
answer
300
views
When I use
ss
(socket statistics) to show the usages of port 5432
I get:
$ sudo ss -ln | grep -E 'State|5432'
Netid State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
u_str LISTEN 0 244 /var/run/postgresql/.s.PGSQL.5432 54481 * 0
tcp LISTEN 0 244 127.0.0.1:5432 0.0.0.0:*
When using lsof
(list of open files) instead I get no result:
$ sudo lsof -i tcp:5432
Why is that?
Related to:
- https://unix.stackexchange.com/q/652556/87249
- [Difference between lsof -i : & socket statistics ss -lp | grep ?](https://stackoverflow.com/q/77685954/334569)
**Edit with answers from comments:**
- sudo ss -lnp
does not show the pid of the process(es) that have that listening socket
- the 127.0.0.1:5432 0.0.0.0:*
on the last line was a copy-paste error, sorry about that, I have removed it
- I am running those commands in a WSL terminal, Postgres is not running anywhere
**Edit with new findings:**
I have found out this is happening only when Docker Desktop is running (even though there is no container running): ss
doesn't output anything once I quit Docker Desktop. It looks like this might be an issue somehow related with Docker Desktop: I have reported it in this GitHub issue.
Asked by Marco Lackovic
(111 rep)
Jun 8, 2024, 08:53 AM
Last activity: Jun 11, 2024, 05:38 PM
Last activity: Jun 11, 2024, 05:38 PM