431
Request Header Fields Too Large
General explanation of the 431 status code
The HTTP status code 431 Request Header Fields Too Large signals that a client request has been rejected by the server because the header fields of the request are too large. This can happen if the request contains an unusually large amount of data in the headers, for example due to overlong cookies, authentication tokens or other metadata. The server is usually unable to process this amount of data as it exceeds the limits it has defined. The error belongs to the category of client errors (400-499), which indicates that the client must adjust the request before it can resend it. One possible solution is to reduce the size of the header data, for example by deleting unnecessary cookies or compressing the data. For developers and administrators, this status code is a helpful indication that either the requests should be optimized or the server configuration should be adjusted to avoid unnecessary blocking. Although the error is on the client side, it can still significantly disrupt communication between the client and server.
Specification of the HTTP status code 431
The 431 Request Header Fields Too Large status code indicates that 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 Request Header Fields Too Large
Content-Type: text/html
Responses with the 431 Request Header Fields Too Large status code MUST NOT be stored by a cache.
Source / Quote by: The 431 Request Header Fields Too Large HTTP Status Code is specified by section 5 of RFC6585.
HTTP-Protocol
How to throw a 431 statuscode with PHP?
To throw the HTTP status code 431 on a web page, the PHP function http_response_code can be used. The syntax is as follows: http_response_code(431) (PHP 5 >= 5.4.0, PHP 7, PHP 8)
Test the 431 HTTP status code
In order to be able to display the HTTP status code (in this case 431 Request Header Fields Too Large) and other information on the client side, the development console must be opened with F12. Afterwards you have to navigate to the tab "Network". Now you can open the page, in the network tab you should see the web page (example index.php). This must be selected and then the Herder section must be selected. Here the user will see the following result:
URL: https://http-statuscode.com/errorCodeExample.php?code=431
Status: 431 Request Header Fields Too Large
Those: Network
IP address: XX.XX.XX.XX
How to create a custom error page for the 431 status code
Apache Webserver
The web server "Apache" is one of the most popular web servers on the Internet. To create an own 431 Request Header Fields Too Large error page in "Apache", the following change must be made in the following file.
NGINX Webserver
Similar to the web server "Apache", "NGINX" is also widely used on the Internet. To create your own 431 Request Header Fields Too Large error page in "NGINX", the following change must be made in the following file.
location = /431.html {
root /usr/share/nginx/html;
internal;
}
Browser compatibility of the 431 status code
Chrome | no data |
Edge | no data |
Firefox | no data |
Opera | no data |
Safari | no data |
Chrome Android | no data |
Firefox for Android | no data |
Opera Android | no data |
Safari on iOS | no data |
Internet | no data |
WebView Android | no data |
Constants in programming languages
HttpStatusCode.RequestHeaderFieldsTooLarge
http.StatusRequestHeaderFieldsTooLarge
Response::HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE
:request_header_fields_too_large