Skip to main content
Interactive nginx-config Configurator →Open Architecture Blueprint ↗
P1 INCIDENTL6 BARM05 · 5 MIN READ

Linux SYN Backlog Drops, Ephemeral Port Exhaustion & TCP BBR

Diagnose silent TCP SYN queue drops, TIME_WAIT ephemeral port exhaustion (EADDRNOTAVAIL), and Cubic packet-loss collapse with ss, nstat, and sysctl tuning.

PRODUCTION SYMPTOM & ALERT SIGNATURE

During traffic bursts, clients see 1-second or 3-second connection stalls and proxy logs emit "Cannot assign requested address (EADDRNOTAVAIL)" while host CPU is under 40%.

rate(node_netstat_TcpExt_ListenOverflows[5m]) > 0 OR rate(node_netstat_TcpExt_ListenDrops[5m]) > 0
01 · ROOT-CAUSE MECHANICS (WHY IT HAPPENS)

When an application calls listen(fd, backlog) with a small backlog (historically 128 or 511) or kernel net.core.somaxconn is too low, burst arrivals overflow the accept queue. Linux silently drops incoming ACKs/SYNs, forcing clients into a 1s -> 3s TCP retransmission backoff.

Outbound proxies opening short-lived TCP connections to a single upstream IP:port exhaust the default ~28,000 ephemeral port range (32768-60999) in TIME_WAIT (60s), throwing EADDRNOTAVAIL.

Over WAN links with 1-2% packet loss, default TCP CUBIC cuts cwnd aggressively on every single loss event, whereas TCP BBR paces traffic from bottleneck bandwidth and min-RTT measurements.

02 · LIVE TRIAGE COMMANDS (COPY & RUN)
Check kernel SYN and accept queue overflow counters
$ nstat -az TcpExtListenOverflows TcpExtListenDrops TcpExtTCPReqQFullDrop
Smoking gun: Non-zero increasing TcpExtListenOverflows / TcpExtListenDrops.
Inspect actual Recv-Q vs Send-Q (effective listen backlog) per socket
$ ss -lnt | head -n 20
Smoking gun: Recv-Q approaching Send-Q (capped at min(app backlog, net.core.somaxconn)).
Verify ephemeral port range and active congestion control algorithm
$ sysctl net.core.somaxconn net.ipv4.ip_local_port_range net.ipv4.tcp_congestion_control
Smoking gun: Small somaxconn, narrow port range, or cubic on lossy WAN edges.
03 · PRODUCTION DIFF (BROKEN VS HARDENED)
BROKEN · Broken Linux Defaults (small accept queue + narrow ephemeral ports)
# Default limits fail under bursty proxy fan-out
net.core.somaxconn = 128
net.ipv4.tcp_max_syn_backlog = 512
net.ipv4.ip_local_port_range = 32768 60999
net.ipv4.tcp_congestion_control = cubic
# Never enable tcp_tw_recycle (removed in Linux 4.12; breaks NAT clients!)
HARDENED · Production Edge Linux sysctl.conf (BBR + high backlog + clean port headroom)
# High-throughput edge / proxy sysctl profile
net.core.somaxconn = 16384
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.ip_local_port_range = 10240 65535
net.ipv4.tcp_tw_reuse = 1
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
# Also bump app-level listen backlog (e.g., nginx listen 443 ssl backlog=16384;)
04 · MINUTE-24 BAR-RAISER CHECKPOINT (L6 · M05)TEST YOUR INSTINCT · ZERO SIGNUP

You raised net.core.somaxconn to 16384, yet ss -lnt still shows Send-Q = 511 on Nginx port 443 and TcpExtListenOverflows keeps climbing. Why?

05 · POST-FIX VERIFICATION CHECKLIST
  • Confirm both sysctl net.core.somaxconn AND the application listen(..., backlog) parameter are raised (the kernel uses min of the two).
  • Verify nstat -az TcpExtListenOverflows stops incrementing under synthetic burst load.
  • Eliminate TIME_WAIT churn at the root by enabling HTTP/1.1 keepalive pooling to upstreams.
06 · FREQUENTLY ASKED ENGINEERING QUESTIONS

Why does TCP BBR require net.core.default_qdisc=fq?

BBR relies on precise packet pacing to avoid filling router buffers; the Fair Queue (fq) qdisc implements kernel-level per-flow pacing cleanly.

Is net.ipv4.tcp_tw_reuse=1 safe for outbound proxy connections?

Yes (for outbound client sockets only, when TCP timestamps are enabled), though enabling HTTP/1.1 keepalive pooling is always the primary fix for ephemeral port exhaustion.

How do I tell if file descriptors (EMFILE) vs ports (EADDRNOTAVAIL) failed?

EMFILE ("Too many open files") means per-process RLIMIT_NOFILE is exhausted (check /proc/<pid>/limits); EADDRNOTAVAIL means the 4-tuple ephemeral port space to that upstream IP:port is full.