Plainnotes

curl has four timeouts; do not set just one

2025-02-19 · 2 min readTools

curl --max-time 10 in a script looks safe but only bounds total time. A connection silently dropped by a firewall stalls the full ten seconds even when three would do.

  • --connect-timeout 3 bounds the TCP handshake.
  • --max-time 10 bounds the whole request.
  • --speed-limit and --speed-time abort a download that has slowed to nothing.
  • Setting both gives a fast failure when the handshake cannot complete.
curl -sS --connect-timeout 3 --max-time 10      --retry 2 --retry-delay 1      -o /dev/null -w '%{http_code} %{time_total}\n' https://example.com/

--retry covers connection errors and 5xx by default; --retry-all-errors widens it.