HAProxy kernel accept-queue overflow: silent SYN drops and somaxconn
Clients report connection timeouts. You open the HAProxy stats page and everything looks fine: session rate is normal, no 5xx spike, servers are UP, Idle_pct is healthy. The network team sees nothing. The clients insist the load balancer is dropping them.
Both sides are right. The kernel is silently dropping SYN packets in the accept queue before they ever reach HAProxy’s event loop. From HAProxy’s perspective, those connections never existed. There is no log line, no error counter, no stat field that increments. The only evidence lives in two kernel counters, ListenOverflows and ListenDrops, that almost nobody graphs.
This guide shows how to confirm it in under five minutes, how to size the fix, and how to monitor the right signals so it never becomes invisible again.
What this means
When a client opens a TCP connection to HAProxy, the path through the kernel looks like this:
flowchart LR C[Client SYN] --> SQ[SYN queue] SQ --> AQ[Accept queue
capped by somaxconn] AQ -->|accept| HA[HAProxy event loop] AQ -.->|queue full| DROP[SYN silently dropped
ListenOverflows +1] DROP --> CT[Client sees timeout] HA --> HB[HAProxy stats
show nothing wrong]
A new connection first lands in the SYN queue while the three-way handshake completes. Once the handshake finishes, the kernel moves the connection into the accept queue for the listening socket, where it waits for HAProxy to call accept(). The size of that accept queue is the backlog value the application passes to listen(), and here is the part that bites operators: if the backlog is larger than net.core.somaxconn, the kernel silently truncates it to somaxconn. No error, no log, no warning in haproxy -c.
When the accept queue is full, the kernel drops incoming SYNs (or the completed handshakes waiting in the queue, depending on the state). The client retransmits, eventually gives up, and reports a connection timeout. HAProxy never sees any of it.
Three things make the queue fill up:
- The queue is too small for the burst.
somaxconn(andnet.ipv4.tcp_max_syn_backlog) is sized below the peak connection arrival rate. - HAProxy cannot call
accept()fast enough. The event loop is saturated (checkIdle_pct) or there are too few threads, so completed connections pile up in the kernel waiting to be accepted. - A genuine connection flood. DDoS, a misbehaving client retrying aggressively, or a thundering herd after an upstream outage.
One more trap: net.core.somaxconn is namespaced. If HAProxy runs in a container with its own network namespace, the container gets the kernel default, not the host’s tuned value. Tuning the host sysctl does nothing for the container’s sockets.
Common causes
| Cause | What it looks like | First thing to check |
|---|---|---|
somaxconn too low for peak connection rate | ListenOverflows increments during traffic bursts only; fine at off-peak | cat /proc/sys/net/core/somaxconn vs peak ConnRate |
| Kernel default still in effect (128 on old kernels, 4096 on modern) | Overflow at surprisingly modest connection rates | sysctl net.core.somaxconn; check container net namespace separately |
| Event loop too busy to accept fast enough | Idle_pct low or near zero, Recv-Q on listen sockets grows under load | show info Idle_pct, show activity per-thread skew |
| Too few threads for the accept rate | One thread doing most accepts; overflow despite low global CPU | show activity per-thread loop and wakeup counters |
| Connection flood / SYN burst | ConnRate far above baseline, ListenDrops climbing fast | ConnRate vs SessRate in show info, stick-table conn_rate per source |
| Backlog silently truncated | HAProxy configured/derived backlog above somaxconn, kernel capped it without error | Compare intended backlog to ss -tln Send-Q on the listen socket |
Quick checks
All of these are read-only and safe to run during an incident.
# 1. The smoking gun: listen overflow and drop counters
nstat -az | grep -i listen
# Look for TcpExtListenOverflows and TcpExtListenDrops.
# These are cumulative; take two samples a few seconds apart to get a rate.
# 2. Current accept-queue depth on HAProxy's listen sockets
ss -tln | grep -E ":(80|443|8404) "
# Recv-Q = connections currently waiting in the accept queue.
# Send-Q = the effective backlog (after kernel truncation to somaxconn).
# Recv-Q persistently near Send-Q means the queue is filling.
# 3. Effective backlog for a specific port, with process info
ss -plnt sport = :443
# 4. What the kernel cap actually is
cat /proc/sys/net/core/somaxconn
cat /proc/sys/net/ipv4/tcp_max_syn_backlog
# 5. If HAProxy runs in a container, check the namespace it actually uses
nsenter -t $(pgrep -x haproxy | head -1) -n cat /proc/sys/net/core/somaxconn
# 6. Can the event loop keep up? (proxy side)
echo "show info" | socat unix-connect:/var/run/haproxy.sock stdio | grep -E "^(Idle_pct|ConnRate|SessRate|CurrConns|Maxconn):"
# 7. Per-thread skew
echo "show activity" | socat unix-connect:/var/run/haproxy.sock stdio
Two things to keep in mind while reading these. First, ListenOverflows and ListenDrops are per-network-namespace counters, not per-socket and not HAProxy-specific. If the host (or namespace) runs other listening services, they contribute too; use ss Recv-Q per port to confirm HAProxy’s sockets are the ones filling. Second, SYN cookies (enabled by default via net.ipv4.tcp_syncookies=1) protect the SYN queue from SYN floods but do not prevent accept-queue overflow. The ListenDrops counter still increments with SYN cookies on, so “syncookies are enabled” is not a reason this cannot be happening.
How to diagnose it
Confirm the symptom is pre-accept loss. Take two
nstat -az | grep -i listensamples 10 seconds apart while clients report timeouts. IfListenOverflowsorListenDropsis incrementing at a nonzero rate, you have kernel-level drops. If both are flat, this article is not your problem; look at HAProxy connection errors (econ) or HAProxy 503 Service Unavailable instead.Confirm it is HAProxy’s sockets. Run
ss -tlnagainst HAProxy’s ports. If Recv-Q is hovering at or near Send-Q during the incident window, HAProxy’s accept queue is the one overflowing. Send-Q also tells you the effective backlog after kernel truncation, which is often smaller than you think.Determine whether the queue is too small or the consumer is too slow. Check
Idle_pctinshow info. If Idle_pct is below ~20% (andbusy-pollingis not enabled), the event loop is saturated and cannot accept fast enough; raising somaxconn will only buy a bigger buffer that drains too slowly. If Idle_pct is healthy and the queue still overflows during bursts, the queue is genuinely undersized for the arrival rate.Check the ConnRate vs SessRate gap. In
show info,ConnRatecounts connections arriving andSessRatecounts sessions established. A persistent gap means connections are being lost or rejected before becoming sessions. The gap is not exclusively caused by accept-queue overflow (ACL denials and rate limits also contribute, viadcon/dseson frontend rows), but combined with incrementing ListenDrops it corroborates pre-accept loss.Check for thread skew. If
nbthread> 1, runshow activityand compare per-thread loop and wakeup counters. One thread running far hotter than the others is a distribution problem;SO_REUSEPORT(via HAProxy’sshardsbind option, available since 2.5) or thread tuning addresses it, not a bigger queue.Rule out a flood. If
ConnRateis far above baseline, you may be absorbing a connection flood rather than a sizing problem. Check stick-tableconn_rateper source if you track it, and frontenddcon/dsesfor TCP-level denials.
Metrics and signals to monitor
| Signal | Why it matters | Warning sign |
|---|---|---|
TcpExtListenOverflows / TcpExtListenDrops (nstat, /proc/net/netstat) | The only direct counter for silent pre-accept drops | Any sustained increment; normally zero or near-static |
ss -tln Recv-Q vs Send-Q on HAProxy ports | Real-time queue depth vs effective backlog | Recv-Q persistently approaching Send-Q |
ConnRate vs SessRate (show info) | Gap hints at connections lost or rejected before sessions | Gap growing during incident windows |
Idle_pct (show info) | Whether the event loop can drain the accept queue | Below ~20% sustained (invalid if busy-polling is on) |
show activity per-thread counters | Hot-thread skew limits accept throughput | One thread doing most of the work |
Frontend scur / slim | Saturation backpressure slows acceptance | scur approaching slim; see scur approaching slim |
Frontend dcon / dses | TCP-level denials also widen the ConnRate/SessRate gap | Spikes coinciding with the gap |
Note the mirror-image failure on the other side: HAProxy’s own ctime (connect time to backends) rises when a backend’s accept queue overflows. Same kernel mechanism, opposite direction. If your symptom is high ctime rather than client-side timeouts, see HAProxy connect time (ctime) high.
Fixes
Raise net.core.somaxconn (and tcp_max_syn_backlog)
If the queue is undersized for your peak connection arrival rate and the event loop has headroom, raise the ceiling:
# Runtime (takes effect for sockets whose backlog exceeds the old cap;
# a HAProxy reload may be needed for the new value to apply to existing listeners)
sysctl -w net.core.somaxconn=65535
sysctl -w net.ipv4.tcp_max_syn_backlog=65535
Persist both in /etc/sysctl.conf or a drop-in under /etc/sysctl.d/. Sizing guidance: the queue absorbs bursts, so size it for the peak connection arrival rate multiplied by the worst-case accept latency you can tolerate, with margin. Modern kernels (5.4+) default to 4096; older kernels defaulted to 128, and many inherited configs still carry that. There is no meaningful cost to a larger cap: memory is only consumed by connections actually queued.
Two caveats. If HAProxy runs in a container, set the sysctl inside the container’s network namespace (or via the orchestrator’s sysctl support), because the namespace does not inherit the host value. And remember the truncation is silent: whatever backlog HAProxy requests, the effective value is min(backlog, somaxconn). Verify the result with ss -tln Send-Q after the change.
Add accept capacity: nbthread and SO_REUSEPORT
If the event loop cannot accept fast enough, a bigger queue just delays the drop. Spread the accept work:
- Raise
nbthreadto use more cores, if the host has spare CPU andIdle_pctshows saturation. - Use
shardson the bind line (HAProxy 2.5+) to create multiple listening sockets on the same address withSO_REUSEPORT. Each shard gets its own kernel accept queue, multiplying total queue depth and distributing accepts across threads. Verify withss -tlnthat you now see multiple listeners. nbprocis the legacy approach and is deprecated in favor of threads plus shards; do not build new deployments on it.
Reduce the burst at the source
If a flood is the cause, queue tuning treats the symptom. Options include rate limiting new connections per source IP with a stick table (conn_rate), fixing a retry-storming client, or absorbing the burst at an upstream layer. During an active flood, raising somaxconn still helps legitimate clients get through, but do not mistake that for the fix.
Do not restart HAProxy first
A restart will drain the queue and make the symptom briefly disappear, which is why this failure so often gets “fixed” without being diagnosed. It also costs you the nstat correlation window and resets all HAProxy counters. Check the counters first, then act.
Prevention
- Graph ListenOverflows and ListenDrops on every HAProxy host. Alert on any sustained increment. This single panel converts the invisible failure into a 30-second diagnosis.
- Alert on Recv-Q near Send-Q for HAProxy listen sockets as a leading indicator, before drops begin.
- Graph ConnRate and SessRate together. A widening gap, correlated with
dcon/dsesand ListenDrops, tells you where connections are dying. - Size somaxconn and tcp_max_syn_backlog deliberately for peak connection rate, in the same sysctl drop-in, in every environment including container namespaces, and verify with
ssSend-Q after every deploy. - Watch
Idle_pct(orshow activityrun-queue depth under busy-polling) so you know whether accept capacity is a queue problem or a consumer problem before the next burst. - Load-test the accept path, not just request throughput. A burst of N new connections per second is a different workload than N requests over keep-alive sessions, and only the former exercises this queue.
How Netdata helps
- Netdata collects the TCP extended counters from
/proc/net/netstat, includingListenOverflowsandListenDrops, per second and per node, so the silent drop becomes a visible, alertable timeseries instead of a counter nobody reads. - The HAProxy collector pulls
show infoand stats CSV over the runtime socket, puttingConnRate,SessRate,Idle_pct,scur/slim, anddcon/dseson the same dashboard as the kernel counters, which is exactly the correlation this diagnosis needs. - Anomaly detection on
ConnRateand session rate surfaces the burst that triggered the overflow, and anomaly flags onListenDropscatch the first increments before clients notice. - Because Netdata monitors the host and HAProxy together, you can see in one view whether the event loop was saturated (Idle_pct collapsing) or idle (queue purely undersized) at the moment drops started, which determines which fix to apply.
Related guides
- HAProxy scur approaching slim: the concurrent-session saturation signal
- HAProxy backend queue building (qcur): requests waiting for a free server slot
- HAProxy connect time (ctime) high: network latency and backend accept-queue overflow
- HAProxy connection errors (econ): backend connections refused, timed out, or reset
- HAProxy 503 Service Unavailable: no server is available to handle this request
- HAProxy 504 Gateway Timeout: timeout server and the backend timeout cascade






