Quit letting your TCP connections hang in FIN_WAIT_2
Performance Tuning & Kernel Parameters (Sysctl)
Quit letting your TCP connections hang in FIN_WAIT_2
🧩 The Challenge
You know that feeling when your web server starts dropping requests because it’s run out of file descriptors, but a quick netstat shows thousands of sockets stuck in FIN_WAIT_2? I’ve spent whole afternoons rebooting services just to clear the pileup before realizing the kernel was just holding onto them way longer than necessary.
💡 The Fix
Lowering the timeout for sockets in that state forces the kernel to reclaim the memory faster so your app can actually accept new traffic. It’s a quick win for high-concurrency environments.
sysctl -w net.ipv4.tcp_fin_timeout=15
⚙️ Why It Works
Setting this value tells the TCP stack to give up on waiting for a remote close after 15 seconds instead of the default, which is often a minute or more. You’re effectively shrinking the graveyard where dead connections go to rot.
🚀 Pro-Tip: Verify the change sticks after a reboot by adding it to /etc/sysctl.conf immediately.
Linux Tips & Tricks | © ngelinux.com | 9/23/2026
