Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku Nginx HTTP 413 entity too large

I'm getting error 413 when uploading a 4MB file. I have already created a .user.ini file on the public/ folder. to allow up to 10 MB files

So I used client_max_body_size like this on my nginx.conf, but I still get 413.

location / {
    index index.php;
    try_files $uri $uri/ /index.php?$query_string;
    client_max_body_size 10M;
}

That configuration is because I'm using Laravel 5.

This is my Procfile

web: vendor/bin/heroku-php-nginx -C nginx.conf public/

Did I do something wrong?

like image 570
Christopher Francisco Avatar asked May 29 '15 20:05

Christopher Francisco


People also ask

How do I fix Nginx 413 Request Entity Too Large?

The solution is to increase the client request size body by the client_max_body_size parameter in nginx. conf file. Following is the description of the client_max_body_size parameter. The default value is 1MB and you can set this to an HTTP, server or location contexts.

How does Nginx handle 413 error?

Error: 413 “Request Entity Too Large” in Nginx with “client_max_body_size” / Changes in Nginx config file. This is happening because of your nginx server not allow to upload file which is larger than defined size in nginx config file.To solve it , you have to modify your nginx configuration.


1 Answers

Perhaps a bit late, but in order to fix this, move your client_max_body_size 10M; outside of the location section. Like this:

client_max_body_size 10M;

location / {
    index index.php;
    try_files $uri $uri/ /index.php?$query_string;
}

See https://github.com/heroku/heroku-buildpack-php/blob/beta/conf/nginx/heroku.conf.php#L35 for reference on how heroku includes this file.

like image 152
Space Devin Avatar answered Nov 02 '22 18:11

Space Devin