# 限制请求，拒绝：429 请求过多

- **ID:** `nginx/limit-req-rejected-request`
- **领域:** nginx
- **类别:** runtime_error
- **错误码:** `429`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

客户端超过了 limit_req_zone 和 limit_req 指令定义的速率限制，导致返回 429 状态码。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| nginx 1.24.0 | active | — | — |
| nginx 1.22.1 | active | — | — |
| nginx 1.20.2 | active | — | — |

## 解决方案

1. ```
   Increase the rate limit in the http block: 'limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;' and adjust the location block: 'limit_req zone=mylimit burst=20 nodelay;' to allow bursts.
   ```
2. ```
   Use a larger burst size to absorb temporary spikes: 'limit_req zone=mylimit burst=50 nodelay;' and ensure the zone size is sufficient (e.g., 10m for 160k IPs).
   ```
3. ```
   Implement client-side retry with exponential backoff to avoid hitting the limit, e.g., in JavaScript with a max retries of 3 and delay doubling.
   ```

## 无效尝试

- **** — worker_connections controls concurrent connections, not request frequency. (90% 失败率)
- **** — Rate limiting occurs at the request level, not the body reading phase. (85% 失败率)
- **** — This removes protection against abuse or DDoS. (10% 失败率)
