TCP State & Port Triage Guide
Pure frontend: pick a symptom, fill in a port and peer address, and get
ss/tcpdumpcommands with branch-specific reading cues. Commands only ever run in your own terminal.
How to use
Choose the symptom closest to what you are seeing. The tool asks for the port and peer address (peer is optional) and writes out a set of copy-ready commands: first a state snapshot, then a packet capture for the relevant phase. Under each command set is tailored guidance on what to look for and which direction to take next.
The first question is always a fork: did it open at all
TCP has eleven states, but triage starts with a single question: did the connection never open, or did it open and then fail? Everything you do next depends on the answer.
If it never opened, you are still in the handshake. Did the SYN get any reply? Did the final ACK leave after SYN-ACK? Is the port actually listening? Is a security group dropping traffic? Failures here usually surface immediately as a connection timeout or connection refused — every new attempt fails.
If it opened and then died, ESTABLISHED existed at some point and was ended by FIN or RST. Now you are asking who closed first, whether it was an orderly four-way close or a forced reset, whether the application is reading data and whether connections are reused. These problems appear mid-request: a reset, a read that fails halfway, or a batch of connections vanishing together.
Mixing the two wastes more time than almost anything else in TCP debugging. You keep confirming the listener is up while the failure actually happens an hour into a transfer; or you rewrite connection handling when the SYN never reached this machine at all.
Where each symptom leads
A pile of TIME_WAIT sockets. This is the normal closing state for the side that initiated the close, held for 2MSL. When the count is high, ask where the sockets sit and whether connections are genuinely short-lived. Load tests, crawler-style calls and missing keep-alive all push it up. Fix connection reuse on the client first; do not rush to change kernel timers or enable sysctls you found in a forum. Shortening those values casually breaks port reuse and stale-packet isolation, buying yourself intermittent faults that are much harder to reproduce.
SYN retransmits and timeouts. The client keeps sending the same SYN because no SYN-ACK arrived. If the server sees the SYN but does not answer, check the listener, half-open queue and kernel drop counters. If the server capture shows nothing, look at the client's egress route, ACLs and security groups. If the server answered SYN-ACK yet the client never sends the final ACK, the return path is the suspect. Distinguish a silent drop from an explicit refusal: an RST means the port is closed or deliberately rejected; repeated retransmits with no RST look more like loss or interception somewhere on the path.
An RST. Reset means terminate now, skipping the four-way close. During the handshake it tends to point at an unlistening port, a full accept queue or a policy rejection. During transfer it more often comes from an application closing a socket with unread data still buffered, a kernel reset after a process crash, or a middlebox stepping in. A single RST proves nothing on its own: record the source address and moment, then line it up with logs from both ends. Always bound the capture by host, port and duration — packets may carry unencrypted payloads, so do not capture full production traffic indefinitely.
CLOSE_WAIT that never falls. The peer sent FIN, you acknowledged it, and your application has not closed its own socket. That is an unambiguous application-level connection leak. Typical causes are returning before the request body was consumed, a cleanup step missing on an error path, or a pool returning a broken connection. The direction is process and code, not firewalls or timeouts.
Three things to keep in mind while reading results
First, a state is a snapshot. ss shows one instant; drawing conclusions without a capture and a connection rate is easy to get wrong. A SYN-RECV backlog needs the queue depth and the application's accept speed alongside it. Plenty of ESTABLISHED sockets with no response may include half-open connections.
Second, align both timelines. The moment the client reported an error, the timestamp in the server log and the RST or final ACK in the capture must match before you have a cause. One side's logs alone often produce the unhelpful conclusion that everything looks normal.
Third, bound your captures. tcpdump needs privileges, and an unbounded capture on a busy interface fills disk and burns CPU. Add a host and port filter, cap the count with -c or the window with timeout, analyse promptly and redact before sharing. A pcap may contain addresses, protocol metadata and unencrypted payloads — it is not a file to forward casually.
Related tutorials
- TCP/IP state machine and troubleshooting — read every column of
ss/netstatand put states back into handshake and teardown order - TCP connection troubleshooting — a structured path through timeouts, resets and pool failures