We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Resolve “413 Request Entity Too Large Error” on Nginx / Apache

Learn how to – Resolve “413 Request Entity Too Large Error” on Nginx / Apache.

Have you encountered an error “413 Request Entity Too Large Error” when trying to upload files to your website?. This often occurs when a request made by the client is too large and cannot be processed by the Web server.

To solve the “413 Request Entity Too Large Error” issue, you need to adjust your Nginx, Apache and PHP configurations. If using CDN, this restriction could also be imposed by the CDN configuration, so ensure you double check.

Change PHP maximum upload values

Open your PHP configuration file. e.g /etc/php.ini and modify maximum upload limits for files.

$ sudo vim /etc/php.ini
upload_max_filesize = 20M
max_file_uploads = 20
post_max_size = 20M

You can also adjust maximum execution time and memory limit for PHP scripts.

max_execution_time = 60
max_input_time = 60
memory_limit = 128M

For Apache on Ubuntu/Debian also update the following file:

$ sudo vim /etc/php/*/apache2/php.ini
upload_max_filesize = 20M
max_file_uploads = 20
post_max_size = 20M

Set client body size – Nginx

Open your Nginx configuration file. This can be global nginx.conf or per site configuration file. Set client body size.

client_max_body_size 20M;

Then restart nginx and php-fpm – Restart commands can vary.

sudo systemctl restart nginx php-fpm

Set LimitRequestBody directive – Apache

If your web server is Apache, set the  LimitRequestBody directive directive.

  # Set to 20 MB
    <Location />
        LimitRequestBody 20971520
    </Location>

Use the Megabytes to Bytes calculator to get your desired values. Also reference Apache  LimitRequestBody directive

Restart Apache web Server when done

# For CentOS / RHEL
sudo systemctl restart httpd
sudo service httpd restart

# Ubuntu / Debian
sudo systemctl restart apache2
sudo service apache2 restart

You have now resolved “413 Request Entity Too Large Error”. Retry to upload your file and it should be successful.

More articles on Nginx:

Cart

Your Cart is Empty

Back To Shop