Fixing 413 Request Entity Too Large Errors

413 request entity too large

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 is setting a particular 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).

It is dependant upon 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

Depending on which web server you use, implement the necessary changes described below to configure your web server’s maximum HTTP request size allowance. By doing so, 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.


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, if it isn’t, you can add that directive in either an http, server, or location block and define a value.

server {
    client_max_body_size 100M;

The default value for this directive is 1 megabyte (1M). 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: service nginx reload.


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 in 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 100MB 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: service apache2 reload.

Additional Configuration – PHP Users

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 will most likely be located in a directory similar to /etc/php5/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 2MB).
  • post_max_size which defines the maximum size of POST data that PHP will accept. This setting also affects the file uploads (default is 8MB).

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: service php-fpm restart.

Leave A Comment?