wget --tries and --retry-connrefused: Retries
wget --tries sets how many attempts a download gets, with --retry-connrefused and --waitretry tuning what and how it retries.
Flaky networks and busy mirrors cause transient download failures. Retry flags turn a one-off blip into a recovered download instead of a failed job.
What it does
wget retries failed transfers up to --tries times (default 20). By default a "connection refused" is treated as fatal and not retried; --retry-connrefused makes wget retry it too. --waitretry adds a linearly increasing wait between retries, and --wait adds a fixed pause.
Common usage
wget --tries=5 --waitretry=10 https://example.com/app.bin
# retry even when the connection is refused
wget --tries=5 --retry-connrefused --waitretry=15 \
https://example.com/app.bin
# give up faster on a dead host
wget --tries=3 --timeout=20 https://example.com/app.binOptions
| Flag | What it does |
|---|---|
| --tries=<n> | Number of attempts (0 or inf means unlimited; default 20) |
| --retry-connrefused | Retry even on connection refused |
| --waitretry=<sec> | Wait up to n seconds, increasing per retry |
| --wait=<sec> | Fixed wait between retrievals |
| -t <n> | Short form of --tries |
In CI
Lower --tries from the default 20 so a truly dead endpoint fails fast instead of stalling the runner for minutes. Combine --tries with --timeout, and add --retry-connrefused when a service may still be booting when the download step runs.
Common errors in CI
Giving up after N retries means every attempt failed; check the underlying error (404 will not be fixed by retries, but Connection timed out or Read error often will). If wget exits immediately on Connection refused, add --retry-connrefused so the attempt is actually retried.