# aiohttp.client_exceptions.TooManyRedirects: 0, message='Too many redirects', url=URL('https://example.com/loop')

- **ID:** `python/aiohttp-too-many-redirects`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The server returned more than max_redirects (default 10) redirect responses, often due to a redirect loop or cookie/auth misconfiguration.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Inspect the redirect chain with curl:

curl -sIL https://example.com/loop | grep -i '^location'
   ```
2. **** (85% success)
   ```
   Handle redirects manually to detect the loop:

async with session.get(url, allow_redirects=False) as r:
    while r.status in (301, 302, 303, 307, 308):
        url = r.headers['Location']
        r = await session.get(url, allow_redirects=False)
   ```
3. **** (82% success)
   ```
   Ensure cookies are sent (some redirect loops happen because auth cookie is missing):

session.cookie_jar.update_cookies({'session': token})
   ```

## Dead Ends

- **** — If it's a true loop, it will still hit 100 and fail. (70% fail)
- **** — You now receive 3xx responses directly and must handle Location yourself. (50% fail)
- **** — Unrelated to redirect count. (90% fail)
