Find answers, guides, and tutorials to supercharge your content delivery.

Fixing 413 Request Entity Too Large Errors

Updated on May 26, 2022
Fixing 413 Request Entity Too Large Errors

The 413 Request Entity Too Large error already gives a hint in its name about what the solution to the problem could be. It's literally a size problem.

This article will go through step-by-step how you can fix the 413 Request Entity Too Large error. As with all error messages, there are more or less elaborate measures you can take to get to the problem's solution. We'll show you how to make the process of fixing the error as simple as possible.

What does 413 Request Entity Too Large mean?

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 sets a specific HTTP request size limit, clients may come across a 413 Request Entity Too Large response. An example request that may cause this error would be if a client was trying to upload a large file to the server (e.g., a large media file).

Meanwhile, the error is also known as the 413 Payload Too Large error. The name has been changed to be more clear and more specific. Nevertheless, you will see the old name much more often in practice.

But why does this error occur at all? The simplest explanation is that the server is set to explicitly deny too large uploads.

It depends on the type of web server you are using, which will determine which directive you need to configure. Whether you want to restrict users from uploading overly large files to your web server or want to increase the upload size limit, the following section will explain how.

Fixing 413 Request Entity Too Large errors

Fixing this error is about increasing the maximum file size for the server in question. Once that is done, the error should no longer occur.

Depending on which web server you use, implement the necessary changes described below to configure your web server's maximum HTTP request size allowance. You can set the threshold file size for which a client is allowed to upload, and if that limit is passed, they will receive a 413 Request Entity Too Large status.

The troubleshooting methods require changes to your server files. For this reason, we recommend that you create a backup before performing the following steps.


For Nginx users, the directive which determines what the allowable HTTP request size can be is client_max_body_size. This directive may already be defined in your nginx.conf file located at /etc/nginx/nginx.conf. However, you can add that directive in either an http, server, or location block and define a value if it isn't.

server {
    client_max_body_size 100M;

The default value for this directive is 1M (1 megabyte). If you do not wish to have a request size limit, you can set the value to 0.

Once you have set your desired value, save your changes and reload Nginx by running the following command: systemctl reload nginx.


For Apache web servers, there is a similar directive called LimitRequestBody. This directive provides the same functionality as client_max_body_size in that you are able to restrict the size of an HTTP request. The LimitRequestBody directive can be defined in your http.conf file or an .htaccess file. The default value for this directive in Apache is 0, however, you may set this value to whatever you like (the value is represented in bytes).

For example, if you wanted to restrict requests larger than 100 MB, you would use the following.

LimitRequestBody 104857600

Once you are done making your changes, save the configuration file and reload Apache using the following command: systemctl reload apache2.

Additional configuration - PHP users

In addition to modifying the appropriate directive on your web server, several other changes are required for PHP users. First, you need to open up your php.ini file, which will most likely be located in a directory similar to /etc/php8/fpm/php.ini (depending on your PHP version). Next, you'll need to find and modify the following directives:

  • upload_max_filesize, which defines the maximum allowed size for uploaded files (default is 2 MB).
  • post_max_size, which defines the maximum size of POST data that PHP will accept. This setting also affects the file uploads (default is 8 MB).

Once the above directives are modified to reflect your desired allowable HTTP request size, simply save the configuration and reload PHP-FPM by running the following command: systemctl restart php-fpm.

KeyCDN uses cookies to make its website easier to use. Learn more