Stop your server from forgetting connections under heavy load
Performance Tuning & Kernel Parameters (Sysctl)
Stop your server from forgetting connections under heavy load
🧩 The Challenge
Dealing with a web server that hits a traffic spike and suddenly throws “connection refused” errors is enough to ruin any weekend. It’s not your app code failing, it’s just the kernel’s queue for new connections getting slammed shut before the application can even blink.
💡 The Fix
Crank up the backlog limit for incoming connections to give your processes more breathing room. It buys your worker threads enough time to pick up those pending requests before the OS drops them.
sysctl -w net.core.somaxconn=4096
⚙️ Why It Works
Setting this parameter increases the maximum number of socket connections held in the listen queue. You will also need to ensure your application code or web server configuration is actually configured to accept a larger backlog, otherwise, the kernel is just waiting for a parade that never shows up.
🚀 Pro-Tip: Check your actual connection drops with netstat -s | grep -i listen to see if you’re even hitting the wall before you change anything.
Linux Tips & Tricks | © ngelinux.com | 8/23/2026
