`ss -tan` shows thousands of sockets in `FIN-WAIT-2` on a server.
IntermediateTroubleshootingSockets, ports, TIME_WAIT and conntrack
Answer
Likely causes → Your side closed and the peer ACKed the FIN, but the peer never sent its own FIN. The remote application is not closing its end (its own CLOSE_WAIT leak), or a middlebox dropped the peer's FIN. Orphaned FIN-WAIT-2 sockets time out after tcp_fin_timeout (60 s default); ones still owned by a process can live longer.
Diagnose →
ss -tano state fin-wait-2 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -rn | head
sysctl net.ipv4.tcp_fin_timeout
Then check the peer host for matching CLOSE_WAIT sockets.
Fix → Fix the peer's connection handling. As a mitigation, lower net.ipv4.tcp_fin_timeout to 15–30 s and make sure your app closes sockets fully (not just shutdown(SHUT_WR) and then forgets them).
Prevent → Track TCP state counts per host as a dashboard; asymmetry between peers points straight at the leaking side.
More on Sockets, ports, TIME_WAIT and conntrack
`dmesg` is full of `nf_conntrack: nf_conntrack: table full, dropping packet` and new connections randomly time out.Intermediate`ss -s` on a reverse proxy shows 40,000 sockets in `TIME_WAIT`. Is that a problem?BeginnerAn app server's `CLOSE_WAIT` count grows steadily until the service logs `Too many open files`.IntermediateLogs show `accept4(): Too many open files` and the service stops accepting connections.Beginner`dmesg` shows `TCP: request_sock_TCP: Possible SYN flooding on port 443. Sending cookies.`Intermediate`ss -ltn` shows the listener for port 8080 with `Recv-Q 129` and `Send-Q 128`, and clients hang on connect.Advanced