Learn how to – Resolve “413 Request Entity Too Large Error” on Nginx / Apache.
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.
![Resolve "413 Request Entity Too Large Error" on Nginx / Apache 1](https://ownyourlife.com.ng/wp-content/uploads/2023/06/solving-request-entity-too-large-nginx.webp)
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.
$ sudo vim /etc/php.ini
upload_max_filesize = 20M
max_file_uploads = 20
post_max_size = 20M
You can also adjust maximum execution time and memory limit for PHP scripts.
max_execution_time = 60
max_input_time = 60
memory_limit = 128M
For Apache on Ubuntu/Debian also update the following file:
$ sudo vim /etc/php/*/apache2/php.ini
upload_max_filesize = 20M
max_file_uploads = 20
post_max_size = 20M
Set client body size – Nginx
Open your Nginx configuration file. This can be nginx.conf
client body size
.
client_max_body_size 20M;
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 20 MB
<Location />
LimitRequestBody 20971520
</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.
More articles on Nginx:
- Setup WordPress Multisite Network with Nginx on Ubuntu |Debian
- Best Apache and Nginx reference Books
- Using Let’s Encrypt Wildcard SSL Certificate with Nginx and Apache
Leave a Reply
You must be logged in to post a comment.