Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx: 413 entity too large - file does not reach the application

I'm using Nginx and uwsgi with wsgi app. When I try to upload the image sometimes the application does not get the image and there used to be error 413 entity too large.

I fixed this issue by adding client_max_body_size 4M;and my Nginx conf looks something like:

//Add sample Nginx Server
//Block here

The error stopped showing but still the file does not reach the application. I don't understand it works on some computers and it dosent work on some.

like image 569
rakesh Avatar asked May 01 '13 02:05

rakesh


2 Answers

If you’re getting 413 Request Entity Too Large errors trying to upload, you need to increase the size limit in nginx.conf or any other configuration file . Add client_max_body_size xxM inside the server section, where xx is the size (in megabytes) that you want to allow.

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        client_max_body_size 20M;
        listen       80;
        server_name  localhost;

        # Main location
        location / {
            proxy_pass         http://127.0.0.1:8000/;
        }
    }
}
like image 109
ajtrichards Avatar answered Sep 22 '22 08:09

ajtrichards


It means the max file size is larger than the upload size. See client_max_body_size

So try using instead of using a fixed value.

server {
     [...]
     client_max_body_size 0;
     [...]
}

A value of 0 will disable the max upload check, I'd recommend putting a fixed value such as 3M, 10M, etc... instead though.

like image 45
Charles R. Portwood II Avatar answered Sep 22 '22 08:09

Charles R. Portwood II