DEV Community

Cover image for How to Resolve Error 413 Request Entity Too Large in Nginx and Amazon EC2 Instance
Autoai Pal
Autoai Pal

Posted on

How to Resolve Error 413 Request Entity Too Large in Nginx and Amazon EC2 Instance

while running on Amazon server instance with Nginx, at some point you might come across an HTTP 413 error that says

request too large

This means that the upload max size has been exceeded. To solve this error follow the steps below

How To solve NGNIX 413 Request Too Large Error

  1. Login to your server via ssh

  2. open the Nginx config file via nano or your favorite text editor. we will use nano for this tutorial

  3. sudo /etc/nginx/nginx.conf

  4. Add this code to the HTTP block
    client_max_body_size 20M;
    Increase the size as you want

  5. save the file and close the editor
    Run this command to restart Nginx

sudo systemctl restart nginx

Now go back and retry the upload again, and it will work

What we have done is increase the maximum allowed file upload size to 20 megabytes. This way any file less than or equal to 20M will be uploaded

So feel free to adjust the value to your need

Top comments (0)