Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

TCP State Machine Reference

Direct answer

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.

When to use this

Use it for a quick diagnosis without a capture: a pile of connections in one state says where things are stuck.

First 30 seconds

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.

Operational verification

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
Platform / version applicability
Protocol standard + deployed implementation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformProtocol standard
Key commandss -tan
Scope / prerequisiteUse it for a quick diagnosis without a capture: a pile of connections in one state says where things are stuck.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Command lookup Jump straight to Cisco syntax
Key points

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.

Key checks
  • ss -tan — every TCP socket with state and endpoints (netstat -an elsewhere).
  • 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

StateThis end has……and is waiting for
LISTENA server socket openAn incoming SYN
SYN-SENTSent a SYNThe SYN-ACK
SYN-RECEIVEDReceived a SYN and sent SYN-ACKThe final ACK of the handshake
ESTABLISHEDCompleted the handshakeData, or a close
FIN-WAIT-1Sent a FIN (it closed first)The acknowledgment of its FIN
FIN-WAIT-2Had its FIN acknowledgedThe other side's FIN
CLOSE-WAITReceived the other side's FINIts own application to close the socket
LAST-ACKSent its own FIN after receiving oneThe final acknowledgment
TIME-WAITFinished closing, as the side that closed firstA fixed time to pass (about a minute) before the connection is forgotten
CLOSEDNothing—

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-WAITThe 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-2The remote application is not closing its side
TIME-WAITA busy client or proxy closing many short connections; normal, but can exhaust local ports
ESTABLISHED, idle for hoursConnections 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)

StateEventNext state
ESTABLISHEDFIN receivedCLOSE-WAIT
ESTABLISHEDApplication closes, FIN sentFIN-WAIT-1
FIN-WAIT-1Our FIN acknowledgedFIN-WAIT-2
FIN-WAIT-1FIN received before our FIN is acknowledgedCLOSING
FIN-WAIT-2FIN receivedTIME-WAIT
CLOSE-WAITApplication closes, FIN sentLAST-ACK
LAST-ACKOur FIN acknowledgedCLOSED
TIME-WAIT2×MSL expiresCLOSED

State counts as a health check

PatternInterpretationOwner
CLOSE-WAIT growingThe application never closes its socketsApplication
SYN-RECV growing on a serverSYN flood, or ACKs not returningNetwork or security
FIN-WAIT-2 piling upThe peer never sends its FINPeer application
TIME-WAIT in the tens of thousandsMany short connections closed by this hostUsually fine; reuse connections
LISTEN missingService not running or bound to another addressApplication
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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docProtocol standard + deployed implementation RFC 9293

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%
Terminology layer

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.

Aliases that resolve here
tcp statessyn sent close waittime wait
Embedded quick reference

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.

Confirmation

Confirm action

Continue?