414 Request-URI Too Large
The HTTP 414 URI Too Long response status code is used to indicate that the Uniform Resource Identifier (URI) requested by the client exceeds the maximum length allowed by the server. This means the server is unable to process the request due to the URI being too lengthy.
To resolve this problem :
- By POST request: Convert query string to json object and sent to API request with POST.
- By GET request: Max length of request is depend on sever side as well as client side. Most webserver have limit 8k which is configurable. On the client side the different browser has different limit. The browser IE and Safari limit to 2k, Opera 4k and Firefox 8k. This means that the max length for the GET request is 8k and min request length is 2k.
A URL (Uniform Resource Locator) is a character string used to reference a particular resource. While there is no universal maximum URL length specified in the HTTP protocol, practical limits are imposed by web browsers and server software, which can vary significantly. To ensure compatibility across different client and server software, it is advisable to keep URLs under 2000 characters, as extremely long URLs are typically considered an error.
Possible causes of 414 Request-URI Too Long
- POST to GET : Converting a POST request to a GET request with query information that is too long.
- A redirect loop: If you get into a redirect loop, the resulting URLs get too long, and the error will appear.
- Server Attack : The server is under attack by a client attempting to exploit potential security holes.
When a client (such as a web browser) sends a request to the server, there is often a maximum limit for the request length that the server can handle. If the request exceeds this limit, some servers may choose to truncate the request data outside the limit without any warning, potentially leading to data loss. However, other servers may reject the request entirely and respond with the HTTP status code 414 Request-URI Too Large, indicating that the requested URI (including the entire URL) is longer than the server is willing to interpret. This response allows the client to be aware of the issue and adjust the request accordingly to avoid further errors.
URI character limit
The length of a Uniform Resource Identifier (URI) can vary depending on the browser and platform being used. For example, Chrome has a practical limit of 2MB (2,097,152 characters) for URLs to prevent denial-of-service issues in inter-process communication, but it limits URL display in the omnibox to 32kB (kMaxURLDisplayChars) on most platforms. In comparison, other browsers like Internet Explorer, Firefox, Safari, and Opera have their own specific limits for URI length, ranging from 1,047 to 190,000 characters. It's essential for developers and website owners to be aware of these limitations to avoid potential issues with their URLs and ensure proper compatibility across different browsers and platforms.
How to solve 414 Request URI Too Large in Apache
- Open Apache Configuration File
- Increase URI limit
- Restart Apache web server
The issue of encountering "Request URI Too Large" errors might be attributed to Apache's limitations on the size of a client's HTTP request-line and the HTTP request header field. Apache allows customization of this limit through the configuration directive called LimitRequestLine. By increasing this value to a size larger than its default of 8190, you can accommodate longer request URIs and avoid the error. However, it's essential to exercise caution while modifying these limits, as excessively large values could potentially lead to performance and security concerns.
Open Apache Configuration File
Open terminal and run the following command to open Apache configuration page.
It is important to note that Apache configuration file is located depending on your Linux distribution. Moreover, if you make changes in Apache server configuration file, it will be applicable for all websites/domains that you run on your Apache web server.
Increase URI limit
Under Apache, the limit is a configurable value, LimitRequestLine. If you want to increase URL limit to 5000 characters (bytes), add the following lines to your server configuration or virtual host file.
If you want to increase maximum header length supported by Apache to 3000 characters, then add the following line.
Restart Apache web server
Now you can restart Apache web server to apply changes.
The HTTP status code 414, "Request-URI Too Large," is returned by the server when the requested Uniform Resource Identifier (URI) exceeds the server's limit for interpreting the URI length. This error occurs when the client's HTTP request contains a URI that is too long for the server to process, prompting the server to reject the request.