Nginx is a popular web server and its default configuration can handle large bodies without issue. However, if you’re intending to send a large body through Nginx, you may need to adjust its default settings. In general, Nginx can handle up to 2GB of data per request. However, if your body is larger than that, it may cause problems. For example, if your body is over 4GB in size, Nginx will start to fill up the memory of your server and will be unable to serve the page properly. To avoid this issue, you can adjust Nginx’s maximum size limit in its configuration file. To do so, open its file in a text editor and add the following line: max_body_size = 10240


What’s actually happening is that I just built this site on a new server, and I was trying to upload a large image for an article that I’m writing. The image is only 1.5mb but on the web that’s very large, so nginx is probably blocking it. Usually you can just upload a smaller image and it’ll be fine, but why let the error keep us down?

Most likely the problem is a bad configuration somewhere. And… sure enough.

Fixing the Error

You’re going to need to go find your nginx configuration files. On my server they are located under /usr/local/nginx/conf/ and there is a sites-enabled folder that has the actual site file. You can either add this option under nginx.conf or the specific site config file found in the sites-enabled folder. What you’re looking for is a section that looks kinda like this:

Once you find that, you know you’re in the right place. Underneath that, you’re going to want to add this line, which will set the max body size for an incoming client request to 5 MB. You can change it to 10MB or 100MB or any other value that you’d prefer, but 5MB was a good value for our purposes.

Of course, you should consider carefully whether allowing larger requests is something you want to do, because it can be a security issue to allow huge requests to come in, especially if you get hit by a DDoS or just a misconfigured client script.