Upload error 413 “Request Entity Too Large” on Nginx

When trying to upload files to a Drupal installation running on nginx, we got a 413 error: Request Entity too large.

 

We had gone through and updated the php files with regard to max upload file size limits, but had neglected to do the same to the nginx config file (/etc/nginx/nginx.conf on Debian). We had to add the following line:

client_max_body_size 20M;

 

in the http block and restart the nginx server to get uploads working again. The above will set the limit to 20MB; change it to suit your own environment and needs.

 

You can also add this to the server or location blocks.