devkult_
tools29converters34

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.

Class4xx Client Error
Retry?No — change the request first
Cacheable by defaultNo — only with explicit Cache-Control
Response bodyAllowed
Defined inRFC 6585 §5 — 431 Request Header Fields Too Large
Example response
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 Authorization header.
  • Proxies adding large forwarding headers.

How to fix it

  1. Clear the site's cookies (on localhost this fixes most cases).
  2. Keep tokens small: store session data server-side and send a reference.
  3. Raise the limit if needed: Node --max-http-header-size, nginx large_client_header_buffers.

Useful here: JWT Decoder

Send a 431 from your server

Express
res.status(431).json({ error: "Request Header Fields Too Large" });
Next.js route handler
return Response.json({ error: "Request Header Fields Too Large" }, { status: 431 });
Flask
return {"error": "Request Header Fields Too Large"}, 431
Go net/http
http.Error(w, "Request Header Fields Too Large", http.StatusRequestHeaderFieldsTooLarge)
nginx
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.

Headers used with 431
Related status codes