DB / Nginx / 413
WARNING
Nginx Request Entity Too Large
The HTTP 413 error occurs when a client (e.g., a browser) sends a request body (like a file upload) that exceeds the limit defined by the `client_max_body_size` directive in the Nginx configuration.
Common Causes
- Uploading a file larger than the default or configured `client_max_body_size` limit (default is often 1MB).
- Misconfigured or missing `client_max_body_size` directive in the relevant server or location block.
- A large POST request payload from an API client or web application.
- Inherited limit from a parent configuration block that is too restrictive.
How to Fix
1 Increase client_max_body_size in Nginx Config
Set or increase the `client_max_body_size` directive in the appropriate server or location block (e.g., for uploads).
BASH
$ server {
# ...
client_max_body_size 20M;
# ...
} 2 Apply Limit to Specific Location
Apply a larger size limit specifically to an upload endpoint or location.
BASH
$ location /upload {
client_max_body_size 100M;
# ... proxy_pass or other directives
} 3 Test Configuration and Reload Nginx
After editing the configuration file, test for syntax errors and reload Nginx to apply changes.
BASH
$ sudo nginx -t
sudo systemctl reload nginx # or sudo nginx -s reload