Differences

This shows you the differences between two versions of the page.

Link to this comparison view

how_to_fix_nginx_error_413_request_entity_too_large_en [2017/09/05 12:18] (current)
Line 1: Line 1:
 +====== How to Fix Nginx Error 413: Request Entity Too Large ======
  
 +Error 413 is a very common Nginx error. It can be found on Nginx as a stand alone server or while using proxy-based solutions, when Nginx is acting as a front end server for Apache on the back end.
 +
 +===== Why do you get the Nginx 413 Request Entity Too Large error? =====
 +
 +
 +This error occurs when your applications is trying to get more information than what is limited by the PHP configuration. Nginx has a directive called client_max_body_size. This variable assigns the maximum accepted body size of any request made by the client.
 +
 +You can see this in the web headers at the Content-Length line. If the size is greater than the one your PHP is running, you will get a “Request Entity Too Large” (413) error.
 +
 +===== How can you fix it? =====
 +
 +
 +In order to fix this issue, you will have to edit the nginx.conf main configuration file.
 +
 +Search for this variable: client_max_body_size. If you find it, just increase its size to 8M, for example. If it doesn’t exist, then you can add it:
 +
 +<sxh bash>
 +vim /​etc/​nginx/​nginx.conf
 +[...]
 +client_max_body_size 8M;
 +</​sxh>​
 +
 +
 +Reload Nginx to apply the changes:
 +<sxh bash>
 +service nginx reload
 +</​sxh>​
 +
 +===== Modifying PHP upload settings =====
 +
 +
 +It’s not needed on all configurations,​ but you may also have to modify the PHP upload settings. Then, you’ll move to the last step to modify your upload general PHP configuration:​
 +
 +Find your php.ini file and modify it using nano. Example: (CentOS path is /​etc/​php.ini) or (Debian path is /​etc/​php5/​fpm/​php.ini)
 +
 +<sxh bash>
 +vim php.ini
 +; Modify the maximum size of uploaded files:
 +[...]
 +upload_max_filesize = 8M
 +[...]
 +; Modify the maximum size of post data:
 +post_max_size = 8M
 +</​sxh>​
 +
 +Finally, reload Nginx to apply the changes:
 +
 +<sxh bash>
 +service nginx reload
 +</​sxh>​
 +
 +At this time, you should be able to try this configuration with 8M or even more. It all depends on how much information your app is requesting from the client. Tweak as needed.
 +
 +
 +====== References ======
 +  - https://​www.scalescale.com/​tips/​nginx/​fix-nginx-error-413/​