Long-lived connections through a Linux NAT box get reset, and conntrack logs show packets classified as `INVALID`.
AdvancedTroubleshootingSockets, ports, TIME_WAIT and conntrack
Answer
Likely causes → Conntrack tracks TCP windows strictly. Packets that fall outside the tracked window (after heavy reordering, a conntrack table restart, or a flow that started before the box took over) are marked INVALID, and a typical ruleset drops them or doesn't NAT them, so they leak with the private source and the peer answers with RST.
Diagnose →
sudo conntrack -S | grep -o 'invalid=[0-9]*'
sudo iptables -L FORWARD -v -n | grep INVALID
sudo sysctl -w net.netfilter.nf_conntrack_log_invalid=6 # log TCP invalids, then check dmesg
Fix → Drop INVALID explicitly so they never leave un-NATed (iptables -A FORWARD -m conntrack --ctstate INVALID -j DROP), and if reordering is expected, set net.netfilter.nf_conntrack_tcp_be_liberal=1 so only out-of-window RSTs count as invalid.
Prevent → Sync conntrack state between HA NAT nodes (conntrackd) and avoid ECMP paths that reorder single flows.
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