LinuxWeb Servers

Fix 413 Request Entity Too Large Errors When Using NGINX

Just like Apache, NGINX imposes default limits on the size of files that can be uploaded. A 413 Request Entity Too Large Error indicates that the file being uploaded to the web server is too large for the settings currently in use. Also, a 408 Request Timeout indicates the server didn’t respond in time. And a 414 Request URI Too Large indicates your URL is too large.

When using Apache, you would use a php.ini or .htaccess file to modify the settings. But for NGINX you modify the virtual host’s file. In this guide, we will take a look at the different settings which will allow us to increase the defaults.

The following settings are all added to the server block in the virtual host’s file located in the /etc/nginx/sites-available folder. To apply these edits server-wide. Place the code in the nginx.conf file located in the /etc/nginx folder.

408 Request Timeout

The request timeout error in NGINX means the connection was received by the server but the NVMe VPS server did not respond in time. The default value for NGINX is 60 seconds. To increase the request timeout add the following code in the server block. Modify as required.

proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_send_timeout 300; 

NGINX 413 Request Entity Too Large

So, to upload larger files to your web server and fix the request timeout error add the following like to the server block. Modify the size limit as required.

client_max_body_size 64M;

414 Request URI Too Large

The 414 Request URI Too Large error indicates that the URL in use is too large for the defaults. So to fix the 414 request URL too large error you increase the header buffer size. But this error is not common. It can also be caused if you are using a proxy. So in those cases, you would need to make changes to your proxy configuration.

client_header_buffer_size 64k;
large_client_header_buffers 4 64k;

These are just some of the NGINX error codes you might come across. All of these errors can easily be fixed by placing the required code inside the server block of the virtual host file. But you can also apply this server-wide if you want. To do this, you would place the required code inside the server block of the nginx.conf file located in /etc/nginx.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button