Stop your server from dropping incoming connections during traffic spikes
Performance Tuning & Kernel Parameters (Sysctl)
Stop your server from dropping incoming connections during traffic spikes
🧩 The Challenge
You ever see your web server randomly refuse connections during a traffic bump, even though CPU and RAM look totally fine? It’s almost always the kernel’s backlog queue getting overwhelmed before your app even gets a chance to see the request.
💡 The Fix
Increase the max size of the connection queue to give the kernel more breathing room when a flood of TCP handshakes arrives. It’s an instant fix for those “connection refused” errors under load.
sysctl -w net.core.somaxconn=4096
⚙️ Why It Works
Setting this value higher tells the kernel to stop being so stingy with its listen backlog queue, allowing more pending connections to wait patiently before they time out or get rejected. You’ll want to make sure your application code is also set to accept these larger queues, or the kernel boost won’t do much.
🚀 Pro-Tip: Check your app’s listen() call; if the backlog argument there is smaller than your sysctl value, the code wins every time.
Linux Tips & Tricks | © ngelinux.com | 9/13/2026
