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.
Kevin Ohashi
Latest posts by Kevin Ohashi (see all)
- Analyzing Digital Ocean’s First Major Move with Cloudways - February 28, 2023
- Removing old companies - June 28, 2021
- WordPress & WooCommerce Hosting Performance Benchmarks 2021 - May 27, 2021
Dude, I’m coming over to your place and baking you the biggest freakin cake you’ve ever seen. I’ve been stuck on this crap for 3 days.
THANK YOU!
All cakes should be sent to Affinity Lab, 920 U St NW, Washington DC. 20001.
Glad I could help 🙂
it works for me thanks
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.
I would imagine fatcow isn’t using Nginx. So it’s probably going to require a different solution. I’m not sure what that is unfortunately.
Thanks!
I encountered this error with a similiar setup while uploading an image and this helped me solve the issue in a pinch.
Really appreciate it! Cheers!
Sharing is caring 🙂 Most of the stuff I write about is issues I ran into and I figure others might too.