In this post, I will explain to you how we can fix the request entity too large issue in the NGINX server. You can get this error when you try to upload a large file in your application. Your web server will fail to upload the file, and you will see the 413 request entity too large error page.
Fixing 413 Request Entity Too Large Error in NGINX server
You need to do two things if you want to fix this error.
Method to fix 413 error
Step 1. Open the terminal and login to your server.
Step 2. Now type nano /etc/nginx/sites-available/mysite_file
you need to open your site config file.
Step 3. Now add client_max_body_size inside your server config as shown in the below snippet
server { client_max_body_size 2000M; listen 80; listen [::]:80; # Other config }
Save (Ctrl+o) and exit (ctrl+x) and restart your server (sudo systemctl restart nginx).
You can also need to update you PHP File uploading size you can update that using the PHP ini_set function
@ini_set( 'upload_max_size' , '64M' ); @ini_set( 'post_max_size', '64M'); @ini_set( 'max_execution_time', '300' );
You need to update your upload max size to handle large file and also need to update your execution time so that PHP server execute your request. Hope you like this post.