4xx Client Errors

HTTP 431 Request Header Fields Too Large

The server is unwilling to process the request because individual header fields are too large.

When is 431 used?

  • Overly large cookies
  • Excessive authorization headers

How to handle a 431 response

Inspect the request — URL, method, headers, credentials, and body. Retrying the same request unchanged will usually fail again; 429 is the exception, where you should wait for the Retry-After period.

Check the status code a URL returns from the command line:

curl -s -o /dev/null -w "%{http_code}\n" https://example.com

How to return 431 from your server

Node.js (Express)

res.status(431).json({ message: 'Request Header Fields Too Large' });

Python (Flask)

return {"message": "Request Header Fields Too Large"}, 431

Go (net/http)

w.WriteHeader(431)

Frequently Asked Questions

What does HTTP 431 mean?

431 Request Header Fields Too Large: The server is unwilling to process the request because individual header fields are too large.

Is 431 an error?

Yes. 431 is in the 4xx Client Errors class. Client errors: the request is malformed, unauthorized, or targets something that does not exist.