Ngnix: 413 – Request Entity Too Large Error
How To

Ngnix: 413 – Request Entity Too Large Error

When we try to upload a large size, then it will not work. The error comes from "413 – Request Entity Too Large". So, we need to change the server default client_max_body_size into Nginx configuration & also the php.ini file if you are using PHP. SO, let's start with the Nginx configuration.

Nginx configuration:

using a text editor such as vi or joe or nano:
# vi /etc/nginx/nginx.conf
Use nano text editor:
$ sudo nano /etc/nginx/nginx.conf
Must be run as root:
# vi /usr/local/nginx/conf/nginx.conf


Add the following line to HTTP context to increase the size limit in Nginx.conf, enter:

# set client body size to 2M #
client_max_body_size 2M;


Save and close the file. After saving to reload/restart your Nginx server

Use Nginx itself to reload it:
# /sbin/nginx -s reload
For RHEL/CentOS/Debian/Ubuntu Linux, try:
# service nginx reload
If you are using systemd based system run:
$ sudo systemctl reload nginx.service


PHP Configuration

//This sets the maximum amount of memory in bytes that a script is allowed to allocate
memory_limit = 512M

//The maximum size of an uploaded file.
upload_max_filesize = 512M

//Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 512M


Hope, it will fix your problems.

Get The latest Coding solutions.

Subscribe to the Email Newsletter