Help
413 Request Entity Too Large in Nginx Ubuntu Server [Solved]

413 Request Entity Too Large in Nginx Ubuntu Server [Solved]

You might get this issue while uploading images either from website or from api request. Whatever is the case, the solution is same and simple. This actually occurs if you don’t have set size limit for uploading files. Or may be because you have set very low size limit. Well, following steps will help you fix this issue.

  1. First access your server using SSH by terminal.
  2. Type following command to open and edit Nginx configuration file. You might ask to type password. Just enter your server password and you are good to go.
    • Remember, while typing password, the characters are not visible.
sudo nano /etc/nginx/nginx.conf
  1. Add following line under http section. You can paste under Basic Settings to make it more searchable later.
    • You can type any size you want. Just make sure, the given size is greater than the size people upload to your server. Otherwise, they will again see the same issue.
    • For now I have set 10M. M means megabyte. If you want to limit with 5 MB, you can use 5M.
http {
     ##
     # Basic Settings
     ##
     client_max_body_size 10M;
}
  1. Once you are done with defining size limit, enter following commands in your terminal step by step.
    • control + x
    • y and
    • Finally enter or return to close and save your file.
    • Remember, if you forgot to type sudo as I mentioned in step number 2, you won’t be able to save nginx.conf file.
  2. One final step and you are done with 413 issue. Type following command in your terminal to restart nginx server.
sudo service nginx restart

And you are done. That’s it. Now try to upload your file once again. You must be able to upload file this time. If you are still not able to upload file and is facing the same problem, let me know. I will be happy to help you.

I Hope this article is helpful to you. If so, don’t forget to share and like this post. That would be highly appreciated.

Thank you.

Leave a Reply