Nginx error 413: Request entity too large Quick Fix
A quick article today about a common error people encounter with Nginx: the infamous 413 Request Entity Too Large HTTP error. I had the problem myself just yesterday on one of my newly configured servers, so I thought I'd make a blog post about it to make sure I don't forget this next time.
Error 413: what does it mean?
This error shows up when a visitor sends too much data in the HTTP request. This is normally caused by:
• an overy large file being uploaded by the visitor
• more generally too much POST data being sent by the client
The fix is as simple as setting a directive in your Nginx configuration, read on below.
The fix is as simple as setting a directive in your Nginx configuration, read on below.
How to fix it? client_max_body_size
To fix this, you need to increase the value of the client_max_body_size directive. This directive defines the maximum amount of data Nginx will accept in an HTTP request. By default this value is set to 1 megabyte, meaning if you attempt to upload a file larger than 1 megabyte you'll be getting an Error 413: Request entity too large page. You can insert this directive at three levels:
- In the http block: this will set the directive value for all server and locations in your configurationn
- In the server block: this will set the directive value for all locations of one particular server
- In the location block: this will set the directive value for one specific location in a particular server
In this example I'm going to insert it in my http block and set it to 500 megabytes:
http {
client_max_body_size 500M; # allows file uploads up to 500 megabytes
[...]
}
Anything else I need to do?
After changing your server configuration, don't forget to reload Nginx for the configuration to apply. There are also some configuration settings you need to change if you are using PHP. If you aren't, just ignore the rest of this post. You'll need to open your php.ini configuration file and look for two values:
- upload_max_filesize: Maximum allowed size for uploaded files (default: 2 megabytes). You need to increase this value if you expect files over 2 megabytes in size.
- post_max_size: Maximum size of POST data that PHP will accept (default: 8 megabytes). Files are sent via POST data, so you need to increase this value if you are expecting files over 8 megabytes.
After making the changes, don't forget to reload PHP-FPM as well so that the changes are applied correctly. That's all! You shouldn't be getting any more upload errors after that.
Comments
However I'm not that into the HTML-stuff and not everybody is anyway.
So how exactly can I fix the problem?
Kind regards
Basically: If you don't know what this post is talking about, there is no way for you to fix it.
vi /etc/nginx/nginx.conf <-- added new html directive.
sudo nginx -s reload <-- nothing printed to screen to confirm the reload, though it must have worked ;)
vi /etc/php.ini <-- changed the default max directives.
service php-fpm restart <-- it worked after the restart!!
Thanks!
I put just the `client_max_body_size 2M;` part so it effects everything for that project.
This reminds me to do it on the production server when I setup a new dev.
I recently have problem with enginx too...after php update i got problem "502 Bad Gateway" and i cant find sollution to solve this
http://www.codingslover.com/2015/05/413-request-entity-too-large-error-with.html
----
facebook movil gratis and facebook movil and apply facebook iniciar sesion celular
packers and movers hyderbad
packers and movers in hyderbad
movers and packers hyderbad
Click Packers
packers and movers hyderabad
packers and movers in hyderabad
movers and packers hyderabad
Click Packers