# aiohttp.client_exceptions.TooManyRedirects: 重定向次数过多

- **ID:** `python/aiohttp-toomanyredirects`
- **领域:** python
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

服务器返回重定向循环（或超过 max_redirects 跳数），通常由 HTTP 到 HTTPS 配置错误或 cookie/会话要求引起。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.9+ | active | — | — |

## 解决方案

1. **** (88% 成功率)
   ```
   async with session.get(url, allow_redirects=False) as r:
    print(r.status, r.headers.get('Location'))
# follow manually and correct the base URL or auth cookie
   ```
2. **** (75% 成功率)
   ```
   session.cookie_jar.update_cookies({'session': token})
async with session.get(url) as r:
    ...
   ```

## 无效尝试

- **** — A true redirect loop never terminates; raising the limit only delays the failure and wastes requests. (80% 失败率)
- **** — You then receive the 3xx response body instead of the target content, so the fetch still fails functionally. (65% 失败率)
