(Last Updated On: January 20, 2019)

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.

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
    </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.