What Is a 431 Status Code?
The server is unwilling to process the request because its header fields are too large. The request MAY be resubmitted after reducing the size of the request header fields.
It can be used both when the set of request header fields in total is too large, and when a single header field is at fault. In the latter case, the response representation SHOULD specify which header field was too large.
For example:
HTTP/1.1 431 Request Header Fields Too Large
Content-Type: text/html
<html>
<head>
<title>Request Header Fields Too Large</title>
</head>
<body>
<h1>Request Header Fields Too Large</h1>
<p>The "Example" header was too large.</p>
</body>
</html>
Responses with the 431 status code MUST NOT be stored by a cache.
- Source: RFC6585 Section 5
431 CODE REFERENCES
Symfony HTTP Status Constant Response::HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE
.NET HttpStatusCode.RequestHeaderFieldsTooLarge
Rust http::StatusCode::REQUEST_HEADER_FIELDS_TOO_LARGE
Rails :request_header_fields_too_large
Go http.StatusRequestHeaderFieldsTooLarge
Python3.5+ http.HTTPStatus.REQUEST_HEADER_FIELDS_TOO_LARGE
Apache HttpComponents Core org.apache.hc.core5.http.HttpStatus.SC_REQUEST_HEADER_FIELDS_TOO_LARGE
Angular @angular/common/http/HttpStatusCode.RequestHeaderFieldsTooLarge
431 status code example
Here’s an example request and response for a 431 status code:
Request
GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Response
HTTP/1.1 431 Request Header Fields Too Large
Date: Mon, 07 Mar 2023 16:12:44 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Retry-After: 3600
Content-Length: 137
<!DOCTYPE html>
<html>
<head>
<title>431 Request Header Fields Too Large</title>
</head>
<body>
<h1>431 Request Header Fields Too Large</h1>
<p>The server is refusing to process the request because the request header fields are too large.</p>
<p>Please try again later.</p>
</body>
</html>
What causes a 431 status code?
A 431 status code occurs when the server rejects a request because the headers are too large. This typically occurs when the client sends too many cookies, which can result in an oversized header. It can also happen when the client sends a large number of headers, or when the server has a limit set on the maximum size of the headers it will accept.
How to troubleshoot a 431 status code
Here are a few possible solutions to a 431 status code:
- Increase the header size limit: The 431 status code occurs when the server rejects a request because the headers are too large. You can try increasing the maximum allowed header size in your server configuration to allow for larger requests.
- Reduce the request header size: If increasing the maximum allowed header size is not possible or feasible, you can try reducing the size of the request headers in your client code. This may involve removing unnecessary headers or compressing headers where possible.
- Use HTTP compression: Another way to reduce the size of headers is to use HTTP compression, which can significantly reduce the amount of data sent in the headers. You can enable compression in your server configuration or use a library or middleware that supports compression.
- Use HTTP/2: HTTP/2 is a newer version of the HTTP protocol that supports header compression and multiplexing, which can reduce the amount of data sent in headers and improve performance. Upgrading to HTTP/2 may help resolve issues with large header sizes.
- Check for proxy or firewall restrictions: The 431 status code can also occur if a proxy or firewall between the client and server is blocking or limiting the size of requests. Check your network configuration to ensure that proxies and firewalls are not interfering with the request headers.
By troubleshooting the above factors, you may be able to resolve the 431 status code error.
Additional resources
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs
- W3Schools
Marketing Tips for Niche Industries
- Travel and Tourism Marketing Budget
- Urgent Care Marketing Ideas: 5 High-ROI Tactics
- Vision Care Industry Statistics
- WebFX: Your Education Digital Marketing Agency
- Why Auto Part Retailers Need Digital Marketing
- Why Digital Marketing is Essential for Auctioneers
- Your Guide to Digital Marketing for Exercise Equipment Companies
- Your Guide to Digital Marketing for Industrial Repair Companies
- 2025 Professional Services Trends: Embracing the Future
- 6 Best Heavy Equipment Marketing Agencies