413 nginx config_error ai_generated true

413 Request Entity Too Large: client intended to send too large body: 2097152 bytes exceeds client_max_body_size

ID: nginx/client-body-buffer-size-exceeded-with-413

Also available as: JSON · Markdown
95%Fix Rate
90%Confidence
1Evidence
2024-01-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
nginx 1.24.0 active
nginx 1.25.3 active
nginx 1.26.0 active

Root Cause

The HTTP request body size exceeds the limit set by the client_max_body_size directive in nginx configuration.

generic

Official Documentation

https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size

Workarounds

  1. 95% success Increase client_max_body_size in the http, server, or location block. Example: http { client_max_body_size 10m; }
    Increase client_max_body_size in the http, server, or location block. Example:
      http {
          client_max_body_size 10m;
      }
  2. 85% success If using a reverse proxy, also ensure the upstream server (e.g., PHP-FPM, Node.js) has matching body size limits. For PHP-FPM, edit php.ini: upload_max_filesize = 10M post_max_size = 10M
    If using a reverse proxy, also ensure the upstream server (e.g., PHP-FPM, Node.js) has matching body size limits. For PHP-FPM, edit php.ini:
      upload_max_filesize = 10M
      post_max_size = 10M

中文步骤

  1. Increase client_max_body_size in the http, server, or location block. Example:
      http {
          client_max_body_size 10m;
      }
  2. If using a reverse proxy, also ensure the upstream server (e.g., PHP-FPM, Node.js) has matching body size limits. For PHP-FPM, edit php.ini:
      upload_max_filesize = 10M
      post_max_size = 10M

Dead Ends

Common approaches that don't work:

  1. Increase client_body_buffer_size only 90% fail

    The error is about client_max_body_size, not client_body_buffer_size. Buffer size is separate from the maximum allowed body size.

  2. Set client_max_body_size in a location block without specifying the server block 50% fail

    If the location block is inside a server block that has a smaller limit, the server block limit may still apply depending on inheritance. Must set at http, server, or location level correctly.

  3. Increase system file descriptor limits 100% fail

    This is a request size limit, not a file descriptor issue.