Fix Error 413 Request Entity Too Large

If you upload a backup file, and you get the error 413 Request Entity Too Large you can do two things:

  1. Upload the backup file manually via FTP or a file manager
  2. Increase the maximum allowed post size

The first option is straightforward and just means that you can upload the backup file to the folder wp-content/uploads/wp-staging/backups

When you did this, and you go to WP STAGING > Backup & Restore you will see the uploaded backup file in the list, and you can proceed with the restore process.

If you want to fix the upload error on the server side you have to make modifications to your web server.

A 413 Request Entity Too Large error occurs when a request made from a client is too large to be processed by the web server. If your web server is setting a particular HTTP request size limit, and the file size exceeds this limit you’ll get that error.

It depends upon the type of web server you are using which directive you need to configure. Whether you want to restrict users from uploading very large files to your web server or want to increase the upload size limit, the section below will explain how to do this.

Fix 413 Request Entity Too Large errors

Apache

For Apache web servers there is a directive called LimitRequestBody. This value is able to restrict the size of an HTTP request. The LimitRequestBody directive can be defined in the http.conf file or in an .htaccess file.

The default value for this directive in Apache is 0. You can set this value to whatever you like. The value is represented in bytes.

For instance, if you like to restrict requests larger than 100 MB you would use the following:

LimitRequestBody 104857600

After making your changes, save the updated configuration file and reload Apache using the command:

service apache2 reload.

Nginx

For Nginx users, the directive for the maximum allowed HTTP request size is client_max_body_size.

This directive may already be defined in the nginx.conf file located at /etc/nginx/nginx.conf.

If it isn’t there, you can add that directive in either an http, server, or location block and define the value:

server {
client_max_body_size 100M;
...
}

The default value for this directive is 1M (1 megabyte). If you don’t want to set a request size limit you can set the value to 0.

Save your changes and reload Nginx by running the command:
service nginx reload

Additional Settings PHP

In addition to modifying the appropriate directive on your web server, there are a couple of other changes required for PHP users. First, you need to open up your php.ini file which is usually located in a directory similar to /etc/php5/fpm/php.ini depending on your PHP version.

Next, find and modify the following values:

upload_max_filesize

This defines the maximum allowed size for uploaded files. The default value is 2 MB.

post_max_size

This defines the maximum size of POST data that PHP will accept. This setting also affects the file uploads and its default value is 8 MB.

After updating the values to your desired allowable HTTP request size, save the configuration and reload PHP-FPM by running the command:
service php-fpm restart

Updated on May 12, 2021