WordPress + Nginx + Uploads = 413 Request Entity Too Large

Happy WordPress Wednesday! The day of the week dedicated to talking about WordPress.

Or sad, if you had to deal with the problem I ran into today while working on our WordPress blog. I wanted to upload some larger pictures and got a cryptic 'HTTP Error'.

Let me explain the architecture I am running here so that this makes sense. I run Nginx as a reverse proxy and caching server in front of Apache. Nginx forwards traffic to apache when it needs to and serves everything from memory when it doesn't (which is incredibly fast).

Back onto the problem, the error message isn't helpful. I did what I normally do, look at the error log. I didn't see anything in the apache log or the nginx log.

What I did discover was by opening Chrome's developer tools and watching the Network tab I could see the file uploads were failing. They were red and had a status code of 413: Request Entity too Large.

Now I know my httpd.conf (Apache's config file) was set to accept files as big as these images.

So now I had to look at the nginx.conf. What I discovered was nginx's default setting is 1 megabyte. So I added this line to my http configuration within nginx:

client_max_body_size 20m;

According to the documentation you can put it in http, server, and location.

A quick

service nginx restart

And all was well in the world.

The following two tabs change content below.
Kevin Ohashi is the geek-in-charge at Review Signal. He is passionate about making data meaningful for consumers. Kevin is based in Washington, DC.

7 thoughts on “WordPress + Nginx + Uploads = 413 Request Entity Too Large

  1. avatarMike Brailer

    Kevin, thank you for reporting on this. I’m having a problem that is similar to yours, regarding plugins designed to allow users to add images to their comments. I’ve tried three plugins for this purpose, and all three fail with images larger than about 50kb, throwing the “Request Entity Too Large” error.

    However, WordPress’ core file upload function doesn’t fail with these files. I can use the Media Library to upload images as large as I need.

    I’m hosting with FatCow and I don’t think I can edit my .conf files myself, but I assume I can ask them to make changes for me.


Leave a Reply

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

Current day month ye@r *


Interested in seeing which web hosting companies people love (and hate!)? Click here and find out how your web host stacks up.