How to Fix 'Client Intended to Send Too Large Body' Nginx 413 Error


This can happen when a user upload a very large sized file to our app that served with Nginx. Maybe the user see the following error


And when we search for an error log for this in Nginx error log in - for example - for CentOS it is located at /var/log/nginx/error.log, we found Client Intended to Send Too Large Body: xxxxxx bytes error.

Let’s fix this by adding a rule in our Nginx config file. We need to add client_max_body_size rule.

Setting for Spesific Site Only

If you want this rule for spesific site only, set this inside your spesific site config that located at /etc/nginx/sites-available/

For example We can use nano to open the config file

sudo nano /etc/nginx/sites-available/

Then insert the following rule

server {
    # set the maximum upload to 20MB
    client_max_body_size 20M;

Setting for All Server Blocks

If we want the rule to affects all server blocks, set it inside /etc/nginx/nginx.conf.

http {
    # set the maximum upload to 20MB
    client_max_body_size 20M;

Note: Setting size to 0 disables checking of client request body size.

Check Nginx Configuration And Restart

Next, check our configuration by running

sudo nginx -t

If it says “syntax is ok” then we are ready to restart our Nginx.

sudo systemctl restart nginx


That’s it, our app should be able to receive files with size under 20MB with this client_max_body_size rule in Nginx.

Read Also


How to Limit File Upload Size in Nginx

Fajarwz's photo Fajar Windhu Zulfikar

I'm a full-stack web developer who loves to share my software engineering journey and build software solutions to help businesses succeed.

Email me
  • Full-Stack Laravel: Forum Web App (Complete Guide 2024)
  • Join Coderfren Discord Server: Share knowledge, build projects & level up your skills.





Sign up for my email newsletter and never miss a beat in the world of web development. Stay up-to-date on the latest trends, techniques, and tools. Don't miss out on valuable insights. Subscribe now!


comments powered by Disqus