![]()
Python Requests: How To Retry Failed Requests (2026 Guide)
TL;DR — Python Requests does not retry failed requests automatically. Mount a urllib3.util.Retry strategy on a requests.Session via an HTTPAdapter, or decorate your call with tenacity.@retry. Always include exponential backoff with jitter, only retry on 408, 429 and 5xx by default, and respect the Retry-After header.
In this guide for The Python Web Scraping Playbook, we'll look at how to configure the Python Requests library to retry failed requests so you can build a more reliable system. There are several ways to do this and we'll walk through each in turn:
- Which status codes should I retry?
- Retry With Sessions & HTTPAdapter (urllib3 Retry) — the built-in option
- Retry With Tenacity — the most flexible option
- Build Your Own Retry Logic Wrapper — the simplest custom option
- Respecting the
Retry-AfterHeader - Retrying Async Requests with httpx
- Idempotency: When You Shouldn't Retry
- Frequently Asked Questions
Let's begin...
Need help scraping the web?
Then check out ScrapeOps, the complete toolkit for web scraping.
Which status codes should I retry?
Before you wire up any retry library, decide which failures actually deserve a retry. Retrying a 404 is pointless. Retrying a 403 just gets you blocked harder. The right default set in 2026 is:
| Status | Retry? | Why |
|---|---|---|
| 200 OK | No | Success. |
| 301 / 302 | No (follow instead) | Follow the redirect; Requests does this by default. |
| 400 Bad Request | No | The request was malformed; retrying won't fix it. |
| 401 Unauthorized | No | Missing or invalid credentials; refresh the token instead. |
| 403 Forbidden | No (without a fix) | Anti-bot detection. See How to Solve 403 Errors. |
| 404 Not Found | No | The URL is wrong or the resource is gone. |
| 408 Request Timeout | Yes | Transient — the request didn't reach the server in time. |
| 425 Too Early | Yes | Server is asking you to wait and retry. |
| 429 Too Many Requests | Yes, with backoff | Rate-limited. Honour the Retry-After header if present. |
| 500 / 502 / 503 / 504 | Yes | Transient server problems; retry with exponential backoff. |
| Connection errors | Yes | ConnectionError, Timeout, ChunkedEncodingError. Retry with backoff. |
A short rule of thumb: retry on connection errors, 408, 425, 429 and 5xx — and nothing else. Everything else needs a code fix, not a retry.