Common Short‑Connection Errors [99] and [110] in Linux: Causes, Code Analysis, and Optimizations
This article examines why frequent short‑lived TCP connections on Linux trigger the [99] could not assign requested address and [110] connection timeout errors, explains the underlying TIME‑WAIT port exhaustion and listen‑queue overflow mechanisms, and offers verification experiments and practical mitigation strategies.
When clients frequently use short‑lived TCP connections, they often encounter two common errors: [99] could not assign requested address and [110] connection timeout . The article analyzes the root causes of these errors and proposes optimization measures.
Cause of [99] error : On the client side, massive short connections create many sockets in the TIME‑WAIT state. When the number of TIME‑WAIT ports fills the entire ip_local_port_range (controlled by the kernel parameter net.ipv4.ip_local_port_range ), the kernel cannot allocate a new local port, resulting in error 99. The kernel code decides whether a TIME‑WAIT port can be reused; if tcp_tw_reuse is disabled or the reuse interval is too short, the allocation fails and the error is returned.
The relevant kernel snippet (Linux 2.6.32.70) shows the check that returns 1 for reusable ports and 0 for non‑reusable ports, leading to EADDRNOTAVAIL (error 99).
$cat "net.ipv4.ip_local_port_range = 1024 1024" >> /etc/sysctl.conf && sysctl -p
Verification: after restricting the port range to a single entry, the client indeed receives the [99] error, confirming the analysis.
Cause of [110] error : On the server side, each incoming SYN request passes through the SYN queue and then the ACCEPT queue. The ACCEPT queue length is limited by somaxconn (and the backlog argument to listen() ). When the number of short connections is high, the ACCEPT queue can overflow, causing new SYN packets to be dropped. The client then experiences a timeout because it does not receive an ACK, resulting in error 110.
The kernel code (Linux 2.6.32.70) shows how sk_max_ack_backlog defines the maximum ACCEPT queue size and how sk_acceptq_is_full() determines overflow.
Verification experiments:
Set somaxconn to 128 and backlog to 8192, generate many short connections, and observe many dropped SYNs and client errors.
Set somaxconn to 8192 with the same backlog , repeat the test, and observe no client errors and no dropped SYNs.
Results confirm that increasing somaxconn mitigates the ACCEPT‑queue overflow but does not eliminate the root cause.
Summary : The experimental results and kernel code align with the hypothesis that TIME‑WAIT port exhaustion causes error 99, while ACCEPT‑queue overflow causes error 110.
Solutions :
Increase the client connection timeout (e.g., from 300 ms to several seconds).
Raise the server somaxconn limit (or adjust related kernel network parameters) to alleviate queue pressure.
Use a connection pool on the client side to convert short connections into long‑lived ones, which is the most effective long‑term fix.
Images illustrating the kernel code snippets and test results are included in the original article.
360 Tech Engineering
Official tech channel of 360, building the most professional technology aggregation platform for the brand.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.