Use it for a quick diagnosis without a capture: a pile of connections in one state says where things are stuck.
TCP State Machine Reference
At each end a TCP connection is always in one state — LISTEN, SYN-SENT, SYN-RECEIVED, ESTABLISHED, FIN-WAIT, CLOSE-WAIT, LAST-ACK, TIME-WAIT — and the operating system shows it for every connection.
1. Count connections per state.
2. Many SYN-SENT → the path or a firewall towards the server.
3. Many SYN-RECV → return path, or a SYN flood.
4. CLOSE-WAIT growing → an application fault on this host.
5. "Cannot assign requested address" → ports held in TIME-WAIT; reuse connections.
LISTEN on the server → SYN-SENT / SYN-RECEIVED for a moment → ESTABLISHED → first closer: FIN-WAIT then TIME-WAIT; other side: CLOSE-WAIT then LAST-ACK → closed
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
ss -tanVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational verification Verify boundary
ss -tan
ss -tan state close-wait
ss -tan | awk 'NR>1 {print $1}' | sort | uniq -c
netstat -an -p tcp
show tcp brief all
ss -tan (Linux) lists every TCP socket with its state and both endpoints; filtering by state and counting per state shows where connections pile up. netstat -an gives the same on Windows and other systems. On a Cisco device, show tcp brief all lists the device's own connections and listeners with their state.
Check both ends where possible; the pair of states tells more than either alone.
Known-good: connections are mainly ESTABLISHED, with short-lived entries in the opening and closing states and no state growing steadily.
Step 2 Failure isolation workflow Narrow the fault
- SYN-SENT entries on the client. No reply to the SYN; follow the path and the firewalls towards the server.
- SYN-RECEIVED entries piling up on the server. The server's SYN-ACK or the client's ACK is lost — asymmetric routing — or a SYN flood.
- CLOSE-WAIT growing on a server. The application leaks sockets; restarting it helps temporarily, fixing it is the cure.
- "Cannot assign requested address" on a busy client. Local ports are tied up in TIME-WAIT; reuse connections or widen the port range.
- ESTABLISHED on one end, nothing on the other. A half-open connection; the next packet will be answered with a reset.
- FIN-WAIT-2 lingering. The other side never closed; the entries time out eventually.
- A service refuses connections while showing LISTEN. Its accept queue is full: the application is not accepting fast enough.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
SYN-SENT on a client means SYNs go unanswered. SYN-RECEIVED on a server means the final ACK is not arriving. CLOSE-WAIT growing means the local application is not closing its sockets. Many in TIME-WAIT can exhaust a busy client's ports. States are local: the other end may have forgotten the connection.
ss -tan— every TCP socket with state and endpoints (netstat -anelsewhere).ss -tan state close-wait— one state only.ss -tan | awk 'NR>1 {print $1}' | sort | uniq -c— count per state.show tcp brief all— on a Cisco device.
ReferenceWhat it is1 section · depth on demand
Mechanics & mental model
At each end, a TCP connection is always in one of a small number of states — listening, opening, established, closing. The operating system shows the state of every connection, and each state says what that end is waiting for.
ReferenceWhy it matters1 section · depth on demand
Why it matters operationally
The states are visible without any packet capture, with one command on the host. A pile of connections stuck in one state is a diagnosis in itself: many half-open connections mean the handshake is not completing; many in close-wait mean an application is not closing its sockets.
ReferenceHow it works1 section · depth on demand
How it works
| State | This end has… | …and is waiting for |
|---|---|---|
| LISTEN | A server socket open | An incoming SYN |
| SYN-SENT | Sent a SYN | The SYN-ACK |
| SYN-RECEIVED | Received a SYN and sent SYN-ACK | The final ACK of the handshake |
| ESTABLISHED | Completed the handshake | Data, or a close |
| FIN-WAIT-1 | Sent a FIN (it closed first) | The acknowledgment of its FIN |
| FIN-WAIT-2 | Had its FIN acknowledged | The other side's FIN |
| CLOSE-WAIT | Received the other side's FIN | Its own application to close the socket |
| LAST-ACK | Sent its own FIN after receiving one | The final acknowledgment |
| TIME-WAIT | Finished closing, as the side that closed first | A fixed time to pass (about a minute) before the connection is forgotten |
| CLOSED | Nothing | — |
Opening. Client: SYN-SENT → ESTABLISHED. Server: LISTEN → SYN-RECEIVED → ESTABLISHED.
Closing. The side that closes first goes FIN-WAIT-1 → FIN-WAIT-2 → TIME-WAIT. The other side goes CLOSE-WAIT → LAST-ACK → CLOSED.
The states are local. Each end knows only its own. One end can be ESTABLISHED while the other has long since forgotten the connection — after a crash, or after a firewall dropped it — and neither notices until one of them sends something.
What accumulations mean.
| Many connections in… | Usually means |
|---|---|
| SYN-SENT (on a client) | SYNs are going unanswered: filtered or unroutable |
| SYN-RECEIVED (on a server) | The handshake's last ACK is not arriving: return path trouble, or a flood of forged SYNs |
| CLOSE-WAIT | The local application has been told the other side closed, and is not closing its own socket — an application fault; the number grows until the process runs out of file handles |
| FIN-WAIT-2 | The remote application is not closing its side |
| TIME-WAIT | A busy client or proxy closing many short connections; normal, but can exhaust local ports |
| ESTABLISHED, idle for hours | Connections whose other end may be gone; keepalives would clear them |
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
Reading the TCP state machine
RFC 9293 defines eleven connection states, including the fictional CLOSED. The transitions explain most of what ss or netstat shows. A passive open goes CLOSED → LISTEN → SYN-RECEIVED → ESTABLISHED. An active open goes CLOSED → SYN-SENT → ESTABLISHED. On close, the side that sends FIN first passes through FIN-WAIT-1, FIN-WAIT-2 (or CLOSING) and TIME-WAIT. The other side passes through CLOSE-WAIT and LAST-ACK. From TIME-WAIT, the RFC requires a wait of 2×MSL before the state is removed.
Transitions on close (RFC 9293)
| State | Event | Next state |
|---|---|---|
| ESTABLISHED | FIN received | CLOSE-WAIT |
| ESTABLISHED | Application closes, FIN sent | FIN-WAIT-1 |
| FIN-WAIT-1 | Our FIN acknowledged | FIN-WAIT-2 |
| FIN-WAIT-1 | FIN received before our FIN is acknowledged | CLOSING |
| FIN-WAIT-2 | FIN received | TIME-WAIT |
| CLOSE-WAIT | Application closes, FIN sent | LAST-ACK |
| LAST-ACK | Our FIN acknowledged | CLOSED |
| TIME-WAIT | 2×MSL expires | CLOSED |
State counts as a health check
| Pattern | Interpretation | Owner |
|---|---|---|
| CLOSE-WAIT growing | The application never closes its sockets | Application |
| SYN-RECV growing on a server | SYN flood, or ACKs not returning | Network or security |
| FIN-WAIT-2 piling up | The peer never sends its FIN | Peer application |
| TIME-WAIT in the tens of thousands | Many short connections closed by this host | Usually fine; reuse connections |
| LISTEN missing | Service not running or bound to another address | Application |
host$ ss -tan | awk 'NR>1 {print $1}' | sort | uniq -c | sort -rn
1840 ESTAB
611 TIME-WAIT
187 CLOSE-WAIT
12 SYN-RECV
host$ ss -tanp state close-wait | awk '{print $NF}' | sort | uniq -c | sort -rn | head -3
host$ ss -ltn 'sport = :443'
R1# show tcp brief all | include LISTEN|ESTAB|TIMEWAIT
The second command groups CLOSE-WAIT sockets by process, which points directly to the application that leaks connections.
Documented example, not captured output.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Network & Protocols → TCP State Machine Reference. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc9293.html · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Operational notes
Former standalone Cheat Sheet content now lives directly inside the Topic where it belongs.
TCP States Fast Reference
Endpoint state meanings and first evidence.
LISTEN → waiting for SYN
SYN-SENT → SYN sent, response pending
SYN-RECEIVED → SYN received/SYN-ACK sent
ESTABLISHED → handshake complete
CLOSE-WAIT → peer FIN received, local app must close
TIME-WAIT → active closer protecting old connection state
Always correlate state with packet direction and owning process.