what is 413/414 request URL/entity too large issue?

Vikram Singh Jadon
Dec 17, 2018 · 3 min read
how to resolve 413/414 nginx issue

Ever tried to upload a huge file or send a very large payload in the request?

If yes, you must have received status code 413 from nginx saying that the “request entity is too large for nginx to handle”.

The reason for this error response is because of the “client_max_body_size” parameter in the nginx configuration.

Web servers keep a limit on the maximum size of the request that can be sent to them. This is handled using client_max_body_size parameter. That is because, as mentioned in this stack exchange answer and I quote —

If you configure “client_body_max_size" to a large value, then you are putting your server in the same scenario as by 2013 when Django allowed users to use a very long password forcing Django (rather the server where it is hosted) to perform very expensive hash calculations leading, as you may guess, to a denial-of-service attack against the whole Django’s authentication framework.

In nginx documentation, By default the value of client_body_max_size is 1 MiB.

If it is a requirement to change client_body_max_size in nginx configuration, It can be done in the following way:

  • Run the the following command to editnginx.conf file.
vi /etc/nginx/nginx.conf
  • Add the following line at the top of http, server or location context to edit the size and then save and close the file.
client_max_body_size 10M;
  • Restart nginx using the following command.
sudo service nginx restart

There you go, the maximum permitted request size in nginx configuration has been changed.


HTTP 414 request-URI too large

I encountered this error while working on Open-Source project in elixirAvia Commerce.

The HTTP 414 URI Too Long response status code indicates that the URI requested by the client is longer than the server is willing to interpret.

Talking in terms of “Nginx” web server. This can also be handled in the similar manner as HTTP 413 error. To handle this we have to modify large_client_header_buffers parameter in the server configuration.

As mentioned in the documentation, default size of large_client_header_buffers is 8 KB.

This way you errors pertaining to max size of request payload or request URI can be handled.


AviaCommerce is an open source e-commerce framework written in Elixir, it leverages all the benefits of the battle-tested Erlang runtime mainly high availability and massive scalability. Do check out the Github repository, where all the action happens!

https://aviacommerce.org

If you enjoyed this tutorial, please click the 👏 button and share to help others find it! Feel free to leave a comment below.

Aviabird

Aviabird Technologies provides enterprise software consulting in Angular, Rails, Elixir, Golang, React, Flutter and other technologies.

Vikram Singh Jadon

Written by

Freelance Software Engineer Working on Ruby, Elixir and Devops

Aviabird

Aviabird

Aviabird Technologies provides enterprise software consulting in Angular, Rails, Elixir, Golang, React, Flutter and other technologies.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade