# HTTP/1.1 431 请求头字段过大

- **ID:** `communication/http-431-request-header-fields-too-large`
- **领域:** communication
- **类别:** resource_error
- **错误码:** `431`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

HTTP请求头的总大小超过了服务器的配置限制（通常为8 KB到16 KB）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| nginx 1.26.0 | active | — | — |
| Apache HTTP Server 2.4.59 | active | — | — |
| Node.js 22.0.0 | active | — | — |

## 解决方案

1. ```
   Increase the server's request header buffer size. For Nginx: 'large_client_header_buffers 4 32k;' in http or server block. For Apache: 'LimitRequestFieldSize 16380' in httpd.conf.
   ```
2. ```
   Reduce cookie sizes or move large state to server-side sessions. Example in Express.js: app.use(session({ store: new RedisStore(), cookie: { maxAge: 60000 } })) — store session data server-side instead of in cookies.
   ```

## 无效尝试

- **Increase server memory or CPU** — The error is a hard limit on header size, not a resource shortage; memory increase does not affect the limit. (90% 失败率)
- **Disable all security modules or firewalls** — Most security tools do not cause this error; disabling them may expose the server without fixing the header size issue. (50% 失败率)
