Quit drowning in TCP state exhaustion
Performance Tuning & Kernel Parameters (Sysctl)
Quit drowning in TCP state exhaustion
🧩 The Challenge
Dealing with a load balancer or a high-traffic web server that suddenly stops accepting new connections because your system is stuck in a sea of TIME_WAIT sockets is a special kind of hell. I’ve spent whole nights thinking it was an application memory leak when it was really just the kernel hanging onto closed sockets for too long.
💡 The Fix
You can tell the kernel to recycle those sockets aggressively instead of waiting the full timeout period. It’s a massive relief for high-concurrency servers that churn through connections constantly.
sysctl -w net.ipv4.tcp_tw_reuse=1
⚙️ Why It Works
Setting this flag allows the kernel to reuse an existing TIME_WAIT socket for a new connection if it’s safe from a protocol perspective. It basically tells the TCP stack to stop being so paranoid about stale packets and start opening up capacity.
🚀 Pro-Tip: Don’t just set it in sysctl -w; add it to /etc/sysctl.conf so it actually sticks after a reboot.
Linux Tips & Tricks | © ngelinux.com | 11/5/2026
