How To Fix Nginx 413 Request Entity Too Large

Fix Nginx 413 Request Entity Too Large

In this tutorial, we will show you how to Fix Nginx 413 Request Entity Too Large on a Linux server. For those of you who didn’t know, Nginx is a powerful web server software that can be used on your server. It is also known for its high performance and low memory usage which will allow fewer resources to be used but getting the job done efficiently. A popular setup is to use it as a proxy for Apache, which can then serve application requests.

I’m running an Nginx-powered server I have configured a while ago. One problem I have on my WordPress sites hosted on that environment is that I couldn’t upload files larger than 2MB. I got Nginx: 413 Request Entity Too Large error. After investigating I found the client_max_body_size directive determines the maximum accepted body size of the client request. If the size is greater than the given one, that’s when we get the error “Request Entity Too Large” (413). If you’re getting 413 Request Entity Too Large errors trying to upload files to your webserver, you need to increase the client body size limit in your nginx.conf configuration file.

Fix Nginx 413 Request Entity Too Large

Step 1. First edit nginx.conf.

#nano /etc/nginx/nginx.conf

Add client_max_body_size in http section:

# set client body size to 2M #

http {
    client_max_body_size 2M;

Step 2. Restart the Nginx web server to apply the changes.

service nginx restart

Step 3. Edit PHP configuration (optional).

Your PHP installation also puts limits on upload file size. Edit php.ini and set the following directives:

#nano /etc/php.ini

;This sets the maximum amount of memory in bytes that a script is allowed to allocate
memory_limit = 32M
;The maximum size of an uploaded file.
upload_max_filesize = 2M
;Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 3M

Congratulations! You have successfully Fix Nginx 413. Thanks for using this tutorial for Fix Nginx 413 on your Linux system. For additional help or useful information, we recommend you check the official Nginx website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!