Nginx

Nginx client intended to send too large body

The other day I’ve saw these error in my nginx log:

2023/09/22 08:15:29 [error] 141156#141156: *15 client intended to send too large body: 9921114 bytes, client: 127.0.0.1, server: two.one.mooo.com, request: "POST /wp-admin/update.php?action=upload-theme HTTP/1.1", host: "crushedge.comel.mooo.com", referrer: "http://two.one.mooo.com/wp-admin/theme-install.php?browse=popular"

It turns out I need to increase the nginx conf client_max_body_size directive.

The Nginx client_max_body_size directive controls the maximum size of files that can be uploaded to your server. The default value is 1MB, which is too small for many modern applications. If you are trying to upload a file that is larger than the client_max_body_size directive, you will see an error message in the Nginx logs.

To increase the client_max_body_size directive, follow these steps:

  • Open the Nginx configuration file (/etc/nginx/nginx.conf on most Linux distributions).
  • Add the following line to the http block:
    client_max_body_size 28M;
    This will increase the maximum file upload size to 10MB. You can increase this value to any desired size, but keep in mind that larger file uploads can consume more server resources.
  • Save the configuration file and restart Nginx.

Example:

http {
  client_max_body_size 10M;

  ...
}

Once you have made the change, you should be able to upload files larger than the client_max_body_size directive without any problems.

Note: If you are using a managed WordPress hosting provider, you may not have direct access to the Nginx configuration file. In this case, you will need to contact your hosting provider to request that they increase the client_max_body_size directive for you.

Tips:

  • It is important to set the client_max_body_size directive to a value that is appropriate for your server resources and the applications that you are using.
  • If you are increasing the client_max_body_size directive to allow for larger file uploads, you should also consider increasing the client_body_buffer_size and client_header_buffer_size directives.
  • If you are using a managed WordPress hosting provider, you can use the WP File Manager: https://wordpress.org/plugins/wp-file-manager/ plugin to upload files larger than the client_max_body_size directive.

Troubleshooting:

If you are still having problems uploading files after increasing the client_max_body_size directive, check the Nginx error logs for more information. You may also need to increase the client_body_buffer_size and client_header_buffer_size directives.

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: