Tips / Nginx

How to Fix Nginx Error 413: Request Entity Too Large

Error 413 is a very common Nginx error. It can be found on Nginx as a stand alone server or while using proxy-based solutions, when Nginx is acting as a front end server for Apache on the back end.

Why do you get the Nginx 413 Request Entity Too Large error?

This error occurs when your applications is trying to get more information than what is limited by the PHP configuration. Nginx has a directive called client_max_body_size. This variable assigns the maximum accepted body size of any request made by the client.

You can see this in the web headers at the Content-Length line. If the size is greater than the one your PHP is running, you will get a “Request Entity Too Large” (413) error.

How can you fix it?

In order to fix this issue, you will have to edit the nginx.conf main configuration file:

nano -w /etc/nginx/nginx.conf


nano -w /usr/local/nginx/conf/nginx.conf

Search for this variable: client_max_body_size. If you find it, just increase its size to 8M, for example. If it doesn’t exist, then you can add it:

client_max_body_size 8M;

Reload Nginx to apply the changes:

service nginx reload

Modifying PHP upload settings

It’s not needed on all configurations, but you may also have to modify the PHP upload settings. Then, you’ll move to the last step to modify your upload general PHP configuration:

Find your php.ini file and modify it using nano. Example:

nano -w /etc/php.ini

Modify the maximum size of uploaded files:

upload_max_filesize = 8M

Modify the maximum size of post data:

post_max_size = 8M

Finally, reload Nginx to apply the changes:

service nginx reload

At this time, you should be able to try this configuration with 8M or even more. It all depends on how much information your app is requesting from the client. Tweak as needed.

Did this help you to resolve the issue? Let us know.

Popular search terms:

  • entity too large nginx 1gb
  • kubernetes nginx file upload error 413
  • nginx error 413

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking