Daniel Gaeta
Daniel Gaeta

Reputation: 794

Nginx client_max_body_size not working

This should be a quick fix. So for some reason I still can't get a request that is greater than 1MB to succeed without returning 413 Request Entity Too Large.

For example with the following configuration file and a request of size ~2MB, I get the following error message in my nginx error.log:

*1 client intended to send too large body: 2666685 bytes,

I have tried setting the configuration that is set below and then restarting my nginx server but I still get the 413 error. Is there anything I am doing wrong?

server {
    listen      8080;
    server_name *****/api; (*omitted*)

    client_body_in_file_only clean;
    client_body_buffer_size 32K;
    charset     utf-8;
    client_max_body_size 500M;
    sendfile on;
    send_timeout 300s;
    listen 443 ssl;
    location / {
        try_files $uri @(*omitted*);
    }
    location @parachute_server {
        include uwsgi_params;
        uwsgi_pass    unix:/var/www/(*omitted*)/(*omitted*).sock;
    }
  }

Thank you in advance for the help!

Upvotes: 11

Views: 31291

Answers (4)

Jim Sosa
Jim Sosa

Reputation: 628

One issue I ran into on this was that I was running multiple nginx processes. I'm on a mac and brew should be managing my only instance but there was a separate process and it was what my app was using. So make sure no other nginx processes are running. After that, I only had to set the value in one place (location)

Upvotes: 0

Dzoni
Dzoni

Reputation: 51

I had the same problem. I entered "client_max_body_size" in nginx.conf under the "server" and I was still getting the 413 error. But after I added the same line under the "http" it solved my problem.

Upvotes: 0

Borshon saydur rahman
Borshon saydur rahman

Reputation: 130

Weirdly it works after adding the same thing "client_max_body_size 100M"in http,location,server all the blocks.

Upvotes: 1

CYMA
CYMA

Reputation: 677

I'm surprised you haven't received a response but my hunch is you already have it set somewhere else in another config file.

Take a look at nginx - client_max_body_size has no effect

Upvotes: 4

Related Questions