If you request a very large URL in Apache web server, then it may give “414 Request URI too large” error message. By default, Apache supports URLs with up to 8177 characters, but sometime users even get error with ~4000 characters in URL. In this article we will look at how to fix 414 request URI too large error in Apache.
How To Fix 414 Request URI Too Large in Apache
By default, Apache server supports up to 8177 characters in a URL. However, if you need to request large URLs, or are getting errors with smaller URLs itself, then you need to increase the request size limit in Apache.
You can do this by setting LimitRequestLine and LimitRequestFieldSize directives.
1. Open Apache Configuration File
Apache configuration file is located at one of the following locations, depending on your Linux distribution.
Open terminal and run the following command to open Apache configuration page.
$ sudo vi /etc/httpd/conf/httpd.conf
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.
Also read : How to Enable Apache Server Status Dashboard
Apache Restrict Access by IP in Virtual Host
If you are running multiple websites on Apache server, using virtual host, then open the virtual host configuration file of the website (e.g www.website.com) for which you want to deny access to IP. Let’s say your virtual host configuration file is located at /etc/apache2/sites-enabled/website.conf
$ sudo vi /etc/apache2/sites-enabled/website.conf
Also read : Apache Restrict Access to URL by IP
2. Increase URI limit
To fix 414 Request URI too large error, you need to set LimitRequestLine directive.
If you want to increase URL limit to 10000 characters (bytes), add the following lines to your server configuration or virtual host file.
If you also want to increase maximum header length supported by Apache to 4000 characters, then add the following line to server configuration or virtual host file.
Basically, you need to specify the required number of bytes after LimitRequestLine and LineRequestFieldSize directives.
Also read : How to Enable HTTP2 in Apache
3. Restart Apache web server
Restart Apache web server to apply changes.
# service httpd restart OR # systemctl restart httpd OR # sudo service apache2 restart
Now when a user tries to request a long URL they will not get “414 Request URI too long” error.