← All notes

Python HTTP clients: timeouts and retries in HTTPX and urllib3

Answer: HTTPX's default behavior is to raise a TimeoutException after 5 seconds of network inactivity.

By default, urllib3 retries requests 3 times and follows up to 3 redirects. Its default backoff_factor is 0, so it does not sleep between retry attempts.

HTTPX

urllib3

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: encode/httpx (GitHub), Timeouts (HTTPX docs), BSD-3-Clause (https://raw.githubusercontent.com/encode/httpx/master/LICENSE.md). Copyright (c) 2019, Encode OSS Ltd; encode/httpx (GitHub), Transports (HTTPX docs), BSD-3-Clause (https://raw.githubusercontent.com/encode/httpx/master/LICENSE.md). Copyright (c) 2019, Encode OSS Ltd; urllib3/urllib3 (GitHub), User Guide (urllib3 docs), MIT (https://raw.githubusercontent.com/urllib3/urllib3/main/LICENSE.txt). Copyright (c) 2008-2020 Andrey Petrov and contributors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: encode/httpx (GitHub), Timeouts (HTTPX docs), BSD-3-Clause (https://raw.githubusercontent.com/encode/httpx/master/LICENSE.md). Copyright (c) 2019, Encode OSS Ltd; encode/httpx (GitHub), Transports (HTTPX docs), BSD-3-Clause (https://raw.githubusercontent.com/encode/httpx/master/LICENSE.md). Copyright (c) 2019, Encode OSS Ltd; urllib3/urllib3 (GitHub), User Guide (urllib3 docs), MIT (https://raw.githubusercontent.com/urllib3/urllib3/main/LICENSE.txt). Copyright (c) 2008-2020 Andrey Petrov and contributors.

Cite this

Permanent ID: iil:note:33qehbdw

iinventedlight. 2026. "Python HTTP clients: timeouts and retries in HTTPX and urllib3." iinventedlight Library, iil:note:33qehbdw, version of 2026-11-16. https://iinventedlight.com/library/notes/python-http-timeouts-and-retries/. License: CC-BY-4.0.

@misc{iil_note_33qehbdw,
  author = {{iinventedlight}},
  title = {{Python HTTP clients: timeouts and retries in HTTPX and urllib3}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/python-http-timeouts-and-retries/},
  note = {Permanent ID iil:note:33qehbdw. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-http-timeouts-and-retries.md.