Solve 413 request entity too large issue in nginx

In Nginx server when you try to upload a large file more than 2 MB then the server shows the error message - 

413 Request Entity Too Large

This error message means the Nginx server max file upload size capacity is lower than your requested file size.

To increase the size of file upload follows the following steps:

Step 1:

Open Nginx configuration file for edit - nginx.conf

sudo nano /etc/nginx/nginx.conf

Step 2:

Edit/Add line client_max_body_size in http configuration - 

http {
        proxy_send_timeout 1200s;
        proxy_read_timeout 1200s;
        fastcgi_send_timeout 1200s;
        fastcgi_read_timeout 1200s;
        client_max_body_size 100M;
        .....
        .....
}

Set client_max_body_size 100M;

Set size according your requirements.

Step 3:

Save the file using Ctrl + O then exit by using ctrl + X.

Step 4:

Restart Nginx server using the following command in Ubuntu - 

sudo service nginx reload

 

 

Keywords: