Skip to content

Nginx – 413 request entity too large

Last updated on June 4, 2022

In this tutorial, you will learn how to fix 413 request entity too large issue fix. When a client attempts to upload a large file to a web server, the server responds with a 413 error to the client. So to fix this issue, you have to increase the server’s file size limit.

Nginx increase client_max_body_size

The default value of the client_max_body_size directive is 1M (1 megabyte). You can set the value to 0 to remove the limit.

Edit your nginx.conf file

vi /etc/nginx/nginx.conf

Add a line in the HTTP section and make sure you save the changes using :xi or :wq.

http {
    client_max_body_size 100M;
}

Now restart or reload Nginx – systemctl restart nginx or systemctl nginx reload

Doesn’t use MB it will not work, only the M. Also do not forget to restart Nginx

Additional PHP configurations

upload_max_filesize which defines the maximum allowed size for uploaded files (default is 2 MB).
post_max_size which defines the maximum size of POST data that PHP will accept. This setting also affects the file uploads (default is 8 MB).
memory_limit is the maximum amount of server memory that each PHP script is allowed to consume. 

Update your php.ini (/etc/php5/fpm/php.ini or /etc/php/7.x/fpm/php.ini or somewhere) file with the following settings, don’t forget to update the number as per your needs.

memory_limit = 128M
post_max_size = 20M
upload_max_filesize = 10M

Add finally restart

systemctl php-fpm restart

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments