brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: curl --retry-all-errors waits out a service that is still starting

Curl
~/tips/tip-curl-retry-all-errors

curl --retry 5 --retry-delay 2 --retry-all-errors -fsS -O https://example.com/file.tgz

Repeats a failed request several times, even on errors curl normally treats as final.

Right after a boot or a deploy the first request often meets a closed port.

curl --retry 5 --retry-delay 2 --retry-all-errors -fsS -O https://example.com/file.tgz

By default --retry only repeats after transient errors such as a timeout or an HTTP 408, 429, 500, 502, 503, 504, 522 or 524. --retry-all-errors (7.71.0 and newer) retries on any failure, including connection refused. Without --retry-delay the wait starts at one second and doubles up to ten minutes, and --retry-max-time caps the total. Be careful with POST requests, because a retry can send the same data twice. Keep -f as well, so an HTTP error page is not saved as the download.

Further reading: curl manual

More Curl tips curl --trace-ascii – https://example.com/ Retry-After: 120 curl -fsS --fail-early \ url = "https://example.com/data/latest.json" curl -4 -s -o /dev/null -w '%{remote_ip} %{http_code}\n' https://example.com/ All Curl tips (71) All topics

Link