Nginx powers nearly 25% of websites on the internet.

Just like any other web server, at times it also shows up some errors.

The Nginx error 413 is one such tricky error that returns the “Request Entity Too Large” message. This occurs mainly when the user exceeds the file upload limits.

At Bobcares, we often receive requests to solve the Nginx error 413 as part of our Server Management Services.

So today, let’s get into this error in detail and see how our Support Engineers fix Nginx error effectively.


Causes of Nginx error 413

Let’s get to know more about the error first. As we all know, web servers allow uploading files of a limited size.

Recently, one of our customers approached us with an Nginx error. He was running Nginx as a front-end to PHP based Apache+mod_fastcgi server.

His app lets users upload images of about 2MB in size. But, when the users try to upload a 1.5MB+ size image file using Nginx reverse proxy, they got the error.

Nginx 413 Request Entity Too Large



Our Support Engineers checked and found out that the errors happened due to file size restriction on the server.

And, the error “413- Request Entity Too Large” returns when Nginx server restricts files with the larger size.


How we fix this error?

So far we have seen the causes of the error. Now let’s have a look at some major fixes for this error.

This error occurs when the uploaded file size exceeds the maximum limit. We set this limit in the client_max_body_size directive of the server. Therefore, we fix the error by increasing this configured value.

We can do this in different ways.


1. Nginx configuration

To fix this error, our Support Engineers initially edit the Nginx configuration file. So, we open the terminal or login to the remote server using the SSH client.

Then, we edit the nginx.conf using the command,

vi /etc/nginx/nginx.conf

Next, we add the following line to HTTP or location context to increase the size limit in nginx.conf.

client_max_body_size size;

The client_max_body_size directive assigns the maximum accepted body size of the client request. We give the required value as size.

Then, we reload the Nginx webserver to reflect the changes made.


2. PHP configuration

Sometimes, the server PHP installation also puts limits on upload file size. So, to alter these limits, we edit the php.ini file and set the following directives as per requirement.

memory_limit = value

upload_max_filesize = value

post_max_size = value

Here the values should match each other. We also make sure to restart or reload the Nginx server to reflect the changes made.


3. Permission errors

Apart from changing the Nginx and PHP settings, sometimes we also need to fix the file permission errors with due care.

We check these permissions in the error log file of the webserver.

If we find some errors with the permissions, we correct it using the chmod or chown commands.


[Need help to fix the Nginx error 413?- We’re here to help you.]



In short, the Nginx error 413 occurs when the uploaded file size exceeds the maximum limit allowed by the Nginx server. In today’s article, we discussed the main causes of this error and saw how our Support Engineers fix it effectively for our customers.


Source link


Write A Comment