Under load, `conntrack -S` shows `insert_failed` climbing, and outbound connections from containers fail sporadically.
AdvancedTroubleshootingSockets, ports, TIME_WAIT and conntrack
Answer
Likely causes → A race in SNAT/MASQUERADE: two connections from different containers are assigned the same source port at the same moment; the second conntrack insert fails and the packet is dropped. The client sees a timeout (often 1 s or 5 s extra latency on retry). Very common for high-rate outbound calls and for UDP DNS from pods.
Diagnose →
sudo conntrack -S | grep -o 'insert_failed=[0-9]*'
sudo iptables -t nat -S POSTROUTING | grep MASQUERADE
Fix → Use fully random port allocation on the masquerade rule (--random-fully, which recent Docker, kube-proxy and most CNIs apply), reduce SNAT by using VPC-native pod IPs, and reuse connections with keepalive/pooling. For DNS, use NodeLocal DNSCache or options single-request-reopen.
Prevent → Graph insert_failed per node and include it in node health dashboards.
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