Error 413 Request Entity Too Large

LinuxFault

Cause of Error 413 Request Entity Too Large

413 request entity too large usually occurs when a web server cannot process a request from a client computer/browser if its size is too large or exceeds the specified limit.

If your web server/hosting has HTTP request limit settings, the client is very likely to experience the 413 Request Entity Too Large Error. But of course, this depends on the type or configuration of the web server you are using. This error indicates that you uploaded a file that exceeds the specified limit.

For users of shared hosting services, normally users only need to use it because the service provider has prepared this size limit configuration according to their respective standards.

It's just that sometimes you need a bigger max limit for uploading files. This setting will also allow you to upload large files on the storage media.

How to Solve Error 413 Request Entity Too Large

In this guide, we will cover how to change web server settings so that you can increase the maximum HTTP request size limit.

1. Apache

For those of you who use the Apache web server, in the configuration, there is a feature called LimitRequestBody.

This feature has the same functionality as client_max_body_size which can limit settings on HTTP requests.

The LimitRequestBody feature is usually set in the http.conf file or in the .htaccess file. The default value of this feature is 0, but you can set this value according to your usage needs.

For example, when you need the maximum upload file size is 100MB, then the settings you need to change are as below.

LimitRequestBody 104857600

After you finish changing it, don't forget to restart Apache with the command: service apache2 reload.

2. Nginx

Meanwhile, for those of you who use the Nginx web server, the feature that sets the maximum HTTP Request size is client_max_body_size. This feature is usually added in the Nginx configuration file called nginx.conf which is in the /etc/nginx/nginx.conf folder.

However, if you can't find the client_max_body_size feature setting, you can add it yourself. More or less an example as below.

servers {

   client_max_body_size 100M;

   …

}

The default value of the client_max_body_size function is 1 megabyte (1M). If you don't want a request size limit, you can set it to 0.

After you finish adjusting the configuration as needed, don't forget to restart Apache using the command: service nginx reload.

3. Changing PHP Limits

You can also change some settings on the web server as you need, for example the PHP settings in it.

First you have to open the php.ini file which is usually in the /etc/php5/fpm/php.ini folder (depending on your operating system and PHP version). Then search for the features below and change them according to the size you need.

upload_max_filesize

This feature is useful for setting the maximum size of the data you want to upload (upload) which defaults to 2MB.

post_max_size

This feature is useful for setting the maximum POST data size limit allowed by PHP. This setting will also affect the size of files that are allowed to be uploaded.

After you set the various configurations above, don't forget to restart the PHP service using the command: systemctl restart php-fpm.

Conclusion

Those are some quick ways to solve the 413 request entity too large error on Apache or Nginx. Uploading large files is sometimes necessary, such as uploading files. However, because the web server's default settings limit it, then you can change it yourself using a variety of things that have been discussed.

Post a Comment

© LinuxFault. All rights reserved. Developed by Jago Desain