What ss Does#
ss (socket statistics) displays information about network sockets. It shows what’s listening, what’s connected, and the state of every TCP/UDP socket on your system. It’s the modern replacement for netstat — faster and more capable.
Use it to answer:
- What ports are open on this machine?
- Is my service actually listening?
- Who’s connected to my server?
- Are there stuck or lingering connections?
Common Options#
| Option | Meaning |
|---|---|
-t | Show TCP sockets |
-u | Show UDP sockets |
-l | Show only listening sockets |
-a | Show all sockets (listening + established) |
-n | Numeric output (don’t resolve hostnames or port names) |
-p | Show the process using each socket |
-s | Show socket summary statistics |
-o | Show timer information |
-e | Show extended socket details |
-i | Show TCP internal info (RTT, congestion window) |
-4 | IPv4 only |
-6 | IPv6 only |
These combine naturally into a few standard invocations.
Standard Invocations#
What’s listening on this machine?#
# TCP listeners
ss -tlnp
# UDP listeners
ss -ulnp
# Both TCP and UDP
ss -tulnpThis is the most common use — “is my service running and on what port?”
Output:
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=1024,fd=3))
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=2048,fd=6))
LISTEN 0 128 127.0.0.1:5432 0.0.0.0:* users:(("postgres",pid=3072,fd=5))| Column | Meaning |
|---|---|
State | Socket state (LISTEN for servers) |
Recv-Q | Data queued to be read by the application |
Send-Q | Data queued to be sent (for LISTEN: backlog) |
Local Address:Port | What address and port the socket is bound to |
Peer Address:Port | Remote side (* means any/none for listeners) |
Process | Which process owns the socket (requires -p and often sudo) |
What does the address mean?#
| Address | Meaning |
|---|---|
0.0.0.0:80 | Listening on all interfaces, port 80 |
127.0.0.1:5432 | Listening only on localhost (not remotely accessible) |
*:* | Any address, any port |
:::80 | Listening on all interfaces, port 80 (IPv6) |
Show all active connections#
ss -tunapThis shows everything — listeners and established connections with process info.
Socket summary#
ss -sOutput:
Total: 187
TCP: 45 (estab 12, closed 8, orphaned 0, timewait 5)
UDP: 6Quick way to see the overall connection state of the system.
Filtering#
By state#
# Only established connections
ss -t state established
# Only time-wait sockets
ss -t state time-wait
# Only close-wait (often indicates a problem)
ss -t state close-waitAvailable states:
| State | Meaning |
|---|---|
established | Active connection |
listen | Waiting for connections |
time-wait | Closed, waiting for delayed packets |
close-wait | Remote side closed, local hasn’t yet |
syn-sent | Connection attempt in progress |
syn-recv | Connection received, not yet accepted |
fin-wait-1 | Closing initiated |
fin-wait-2 | Close acknowledged, waiting for remote close |
last-ack | Waiting for final acknowledgment |
closing | Both sides closing simultaneously |
By port#
# Connections on port 443
ss -tn sport = :443
# Connections to remote port 443
ss -tn dport = :443
# Listening on port 8080
ss -tlnp sport = :8080By address#
# Connections to a specific IP
ss -tn dst 10.0.1.50
# Connections from a specific subnet
ss -tn src 192.168.1.0/24Combining filters#
# Established connections to port 443 from a specific subnet
ss -tn state established dport = :443 src 192.168.1.0/24Reading TCP State#
Recv-Q and Send-Q for established connections#
| Column | Healthy | Problem |
|---|---|---|
Recv-Q > 0 | Data waiting to be read | App is slow or stuck |
Send-Q > 0 | Data waiting to be sent | Network congestion or remote not acknowledging |
A consistently growing Recv-Q means the application isn’t reading fast enough. A growing Send-Q means packets aren’t being acknowledged.
Recv-Q and Send-Q for LISTEN sockets#
| Column | Meaning |
|---|---|
Recv-Q | Current incomplete connection queue size |
Send-Q | Maximum backlog (configured limit) |
If Recv-Q approaches Send-Q on a listener, the server is getting overwhelmed with new connections.
TCP Internal Info#
ss -tiShows per-connection details:
cubic wscale:7,7 rto:204 rtt:1.5/0.75 ato:40 mss:1448 cwnd:10 send 77.2Mbps| Field | Meaning |
|---|---|
rtt | Round-trip time (ms) |
cwnd | Congestion window (segments) |
mss | Maximum segment size |
retrans | Retransmission count |
send | Estimated send bandwidth |
Useful for diagnosing slow connections — high RTT or low cwnd indicates a problem.
Practical Scenarios#
Is my web server listening?#
ss -tlnp | grep :80
# or
ss -tlnp | grep nginxIf nothing shows up, the service isn’t running or isn’t bound to the expected port.
Which process is using port 8080?#
sudo ss -tlnp sport = :8080The -p flag with sudo reveals the process name and PID.
How many connections does my server have?#
# Count established connections to port 443
ss -t state established sport = :443 | wc -l
# Count by remote IP
ss -tn state established sport = :443 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -rn | head -10Are there connection issues?#
# Check for close-wait (app not closing connections properly)
ss -t state close-wait | wc -l
# Check for time-wait accumulation
ss -t state time-wait | wc -l
# Check for SYN floods
ss -t state syn-recv | wc -lMonitor connections in real time#
watch -n 1 'ss -s'Find connections to a specific remote server#
ss -tn dst 10.0.1.50Check if a port is externally accessible#
# Locally, check it's listening on 0.0.0.0 (not just 127.0.0.1)
ss -tlnp sport = :5432
# If it shows 127.0.0.1:5432, it's only accessible locally
# If it shows 0.0.0.0:5432, it's accessible from the networkss vs netstat#
| ss | netstat | |
|---|---|---|
| Speed | Fast (reads kernel data directly) | Slow (parses /proc) |
| Status | Current, maintained | Deprecated |
| Filtering | Built-in state/port filters | Requires grep/awk |
| Package | iproute2 (always installed) | net-tools (often missing) |
If you see netstat in documentation, translate to ss:
| netstat | ss equivalent |
|---|---|
netstat -tlnp | ss -tlnp |
netstat -an | ss -an |
netstat -s | ss -s |
netstat -r | ip route (not ss) |
Best Practices#
- Use
ss -tlnpas your first check when a service seems unreachable — confirm it’s actually listening - Always use
-nto avoid slow DNS lookups on busy systems - Use
sudowith-pto see process names — without it, you only see sockets you own - Watch for
close-waitaccumulation — it usually means your application has a connection leak - Check the bind address —
127.0.0.1means local only,0.0.0.0means network-accessible - Use state filters instead of grep when looking for specific connection states — it’s faster and more precise
- Combine with
watchfor real-time monitoring during incident response


