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.

solving request entity too large nginx

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.

upload_max_filesize = 8M
max_file_uploads = 20
post_max_size = 8M

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

max_execution_time = 60
max_input_time = 60
memory_limit = 128M

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 8M;

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 2 MB
    <Location />
        LimitRequestBody 2097152

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.

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here