431 Request Header Fields Too Large
The server refuses the request because its headers are too big, usually because of too many or oversized cookies.
What 431 Request Header Fields Too Large means
Defined in RFC 6585. The limit can apply to all headers together or to a single header. Cookies are the usual culprit, since every cookie for a domain goes out with every request.
Some servers report the same problem as 400. nginx, for example, shows 400 Bad Request with the message Request Header Or Cookie Too Large.
Common causes
- Cookies piling up on a domain, often from analytics, A/B tests or many subdomains sharing cookies.
- A very large Authorization header, such as a JWT carrying too many claims.
- Large custom headers added by a proxy or the app.
How to fix 431 Request Header Fields Too Large
- As a visitor, clear cookies for that site and reload.
- Store less in cookies and scope them to the paths and subdomains that need them.
- Keep tokens small, or raise the header limit (large_client_header_buffers in nginx, --max-http-header-size in Node.js).
Example response
HTTP/1.1 431 Request Header Fields Too Large
Content-Type: text/plain; charset=utf-8
431 Request Header Fields Too LargeHow to check for a 431 response
cURL
# Print only the status code
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/JavaScript (Node.js)
const res = await fetch("https://example.com/");
if (res.status === 431) {
console.log(res.status, res.statusText);
}Python
import requests
res = requests.get("https://example.com/")
if res.status_code == 431:
print(res.status_code, res.reason)Go
res, err := http.Get("https://example.com/")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 431 {
fmt.Println(res.Status)
}Specification
431 Request Header Fields Too Large is defined in RFC 6585, section 5.
Related status codes
- 400
The server could not understand the request because something in it is malformed, like broken JSON, bad syntax or invalid headers.
- 413
The request body is bigger than the server is willing to accept, usually because an upload is over the size limit.
- 414
The URL is longer than the server is willing to process, often because too much data was packed into the query string.