431 Request Header Fields Too Large
4xx client error
The request's headers — often its cookies — are too large for the server.
431 (RFC 6585) means the request's headers, in total or a single one, exceed the server's limit. Cookies are the usual suspect: every cookie for a domain rides along on every request, and analytics, A/B testing and auth cookies add up until a limit — commonly 8 to 16 KB — is crossed. Node.js's default maximum header size is 16 KB.
| Class | 4xx Client Error |
|---|---|
| Retry? | No — change the request first |
| Cacheable by default | No — only with explicit Cache-Control |
| Response body | Allowed |
| Defined in | RFC 6585 §5 — 431 Request Header Fields Too Large |
HTTP/1.1 431 Request Header Fields Too Large
Content-Type: application/json
Content-Length: 43
{"error":"Request Header Fields Too Large"}Common causes
- Too many or too large cookies — especially on localhost, where every project's cookies pile up.
- Huge JWTs packed with claims in the
Authorizationheader. - Proxies adding large forwarding headers.
How to fix it
- Clear the site's cookies (on localhost this fixes most cases).
- Keep tokens small: store session data server-side and send a reference.
- Raise the limit if needed: Node
--max-http-header-size, nginxlarge_client_header_buffers.
Useful here: JWT Decoder
Send a 431 from your server
res.status(431).json({ error: "Request Header Fields Too Large" });return Response.json({ error: "Request Header Fields Too Large" }, { status: 431 });return {"error": "Request Header Fields Too Large"}, 431http.Error(w, "Request Header Fields Too Large", http.StatusRequestHeaderFieldsTooLarge)
return 431;
Check what a URL returns
Print just the status line from the command line, or check a whole list of URLs at once, with their response headers, in the HTTP Status Checker.
curl -sI https://example.com/your-path | head -n 1
Frequently asked questions
Why do I get 431 on localhost?
Every app you've run on localhost shares one cookie jar for that host, so cookies accumulate. Clear them in DevTools → Application → Cookies.
Is nginx's 'Request Header Or Cookie Too Large' the same problem?
Yes, though nginx reports it as a 400 with that message rather than 431. The fix is the same: shrink cookies or raise large_client_header_buffers.