By default, NGINX has a limit on the size of URL, request headers and data that it can handle. If your request exceeds any of these limits, it will throw an error. So when your URL is too long, NGINX will very likely give you a “414 : Request URI too large” error. Let us take a look at how to fix 414 request URI too large in NGINX.
How to Fix 414 Request URI Too Large in NGINX
Here are the steps to fix 414 request URI Too Large in NGINX.
1. Open NGINX config file
Open NGINX config file in a text editor.
You will find it at one of the following locations, depending on the type of installation
/etc/nginx/conf.d/default.conf /etc/nginx/sites-enabled/default /etc/nginx/nginx.conf
$ sudo vim /etc/nginx/nginx.conf
2. Increase Client Header Buffer Size
NGINX allocates temporary buffers to handle requests. These buffers store request URL, header and data. A request header cannot exceed the size of a buffer, otherwise NGINX will give 414 error response. So we increase the header buffer size using the large_client_header_buffers directive.
large_client_header_buffers 4 8k;
Context: http, server
You can place this directive in http or server context.
For example, add this to your NGINX config file.
large_client_header_buffers 4 64k;
If the above solution doesn’t work for you, try setting the client_header_buffer_size
3. Reload NGINX web server
Test the config file to ensure there are no errors.
$ sudo nginx -t
If you get no error message, reload NGINX server to apply changes.
$ sudo service nginx reload
That’s it! NGINX will now be able to handle large URLs.