Observation and diagnostics · Intermediate

Reading socket state with ss

Inspect listening sockets, connection states, and queues to narrow down where a Linux communication problem occurs.

Ask Logeia about this articleTry the three questionsReview your answers

Updated

On this page
  1. Separate listening from established connections
  2. Select the view that answers the question
  3. Interpret queues in the context of state
  4. Know when to move up or down a layer
  5. Ask Logeia about this articleCheck your understanding

Separate listening from established connections

ss displays Linux socket statistics. When TCP communication fails, first check whether the expected local address and port are listening, then examine established or intermediate connection states. A port in a listing does not establish that an application request has completed successfully.

Inspect both endpoint addresses as well as the state. A process listening only on the loopback address is not equivalent to one accepting remote connections. IPv4, IPv6, and container network namespaces can also change which socket population is visible, so identify the observation scope before interpreting absence.

Select the view that answers the question

The first command lists TCP listeners numerically and requests process information where visible. The second inspects established TCP connections with additional internal information. Numeric output avoids name resolution and makes direct address and port comparisons easier when investigating a specific endpoint.

Missing process information with -p does not prove that no owning process exists. Permissions can limit information about another user’s processes, and the namespace in which the command runs limits its view. Record where the service and the observer run rather than interpreting every missing field as an application fault.

shell
ss -ltnp
ss -tin state established

Interpret queues in the context of state

For an established TCP socket, Recv-Q provides evidence about received data not yet consumed by the application. Send-Q relates to outstanding transmitted data. Listening sockets use queue fields for connection backlog information instead, so the same column heading must not be assigned one universal byte-based meaning.

Suppose repeated observations show an established connection’s Recv-Q growing from 4096 to 8192. That motivates asking whether the receiver is reading promptly. It does not prove a cause from one snapshot: correlate application work, peer behavior, CPU load, and I/O waits before deciding whether growth is an ordinary burst or persistent backpressure.

Know when to move up or down a layer

An ESTAB connection can still carry an incorrect HTTP response. Socket statistics do not validate business-level success or inspect encrypted application content. Once connection state looks appropriate, inspect application logs or a protocol-aware test rather than using TCP establishment as a substitute for application verification.

A snapshot also cannot reconstruct every retransmission or disconnect in the past. Correlate observations over time and use packet capture or system-call tracing when needed. The useful outcome is a narrower, testable hypothesis whose scope matches the socket state and the information actually observed.

Reading and practice are recorded separately in this browser, for each language.

Learn this in order

Build your CS foundations · STEP 15

Understand the systems behind the web · STEP 4

Choose a learning path