Advanced socket statistics: filter by state, process, and address.
low risk
ss (socket statistics) is the modern replacement for netstat. Beyond basic port listing, it supports powerful filters by TCP state, destination, source, and process. The state filter lets you count and analyze connections in specific TCP states — critical for diagnosing connection exhaustion.
| Flag | Meaning |
|---|---|
-t --tcp | TCP sockets only |
-u --udp | UDP sockets only |
-l --listening | Listening sockets only |
-p --processes | Show process using the socket |
-n --numeric | Don't resolve hostnames |
-s --summary | Summary statistics |
ss -sSocket summary: total TCP, UDP, ESTABLISHED counts · explain & risk-check →ss -tnp state establishedAll established TCP connections with process names · explain & risk-check →ss -tnp state time-wait | wc -lCount TIME_WAIT connections (connection exhaustion indicator) · explain & risk-check →ss -tnp dst :443All connections to HTTPS port · explain & risk-check →ss -lnp | grep :8080Check what's listening on port 8080 · explain & risk-check →ss -tnp state established '( dport = :5432 )'Active connections to PostgreSQL · explain & risk-check →Use `ss -s` for an instant health snapshot — if TIME_WAIT count is very high (thousands), your app isn't reusing connections. Enable TCP keep-alive or connection pooling.
Reference text is hand-written and may be incomplete — check man ss for your version. Test destructive commands on a non-production system first.