Networking & Firewall (Ss/Netstat/Iptables/Curl)
Stop waiting for curl to hang forever on dead connections
🧩 The Challenge
You ever run a curl command against an internal API, only to have it sit there for minutes while you watch the terminal cursor blink? Half the time the firewall is silently dropping packets, and the default timeout is way too long for anybody’s patience.
💡 The Fix
Just force a connection timeout so the command gives up and yells at you immediately instead of lingering. It saves you from manual intervention when the network path is clearly broken.
curl --connect-timeout 5 --max-time 10 http://your-internal-service.local/api
⚙️ Why It Works
Setting the connect timeout tells curl to stop waiting for the TCP handshake after five seconds, and max-time puts a hard cap on the entire request duration. It prevents those zombie processes that stall your automation scripts for no reason.
🚀 Pro-Tip: Add -v if you want to see exactly where the connection is failing, but remember to pipe it to grep or you’ll get a wall of noise.
Linux Tips & Tricks | © ngelinux.com | 10/26/2026
