Make curl retry failures and respect timeouts

The resilience flags most curl users forget: --retry, --retry-all-errors, --connect-timeout, and --max-time turn flaky downloads into reliable ones.

LinuxcurltimeoutretryLow risk
Run `curl --retry 3 --retry-all-errors --connect-timeout 5 --max-time 60 -fLO <url>` to retry up to 3 times with a 5-second connect limit and a 60-second total deadline.

01Command

Command
$ curl --retry 3 --retry-all-errors --connect-timeout 5 --max-time 60 -fLO https://example.com/file.tar.gz

02What it does

By default curl gives up on the first network error and waits forever for a stalled server, which is why scheduled downloads fail silently. `--retry 3` handles transient errors and honors the server's Retry-After header, but only for a narrow error set unless you add `--retry-all-errors` (curl 7.71+). `--connect-timeout` bounds just the TCP handshake while `--max-time` caps the whole transfer, so a 10 KB file can never hang for an hour.

03Risk

RiskLow risk
Requirementscurl 7.71+ for --retry-all-errors
!Warning: --retry-all-errors will re-send POSTs and other non-idempotent requests — don't use it against payment or order APIs.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-17 · Category: Network