What is the default client_max_body_size in Nginx?
Nginx defaults to a 1 MiB request-body limit. Learn where to override it and what other upload limits still apply.
Nginx defaults to client_max_body_size 1m;: 1 MiB, or 1,048,576 bytes. A request body above the effective limit is rejected with HTTP 413. For multipart uploads, the body includes form fields and boundary overhead as well as the file.
Find the effective setting
sudo nginx -T
Inspect the configuration loaded by the running instance, including all includes, for client_max_body_size. If it is absent from that configuration, the built-in default applies. A recursive search of /etc/nginx can help, but it does not prove that a custom installation uses those files. Keep the dump private because other settings may contain sensitive values.
Override it at the right scope
http {
client_max_body_size 50m;
server {
client_max_body_size 100m;
location /upload {
client_max_body_size 500m;
}
}
}
This shows valid contexts, not a complete upload service. Preserve the handler in the selected location. A setting in a child context overrides its inherited value; check which location actually handles the request.
sudo nginx -t && sudo systemctl reload nginx
Use the appropriate equivalent for your process manager. 0 disables Nginx's body-size check; it does not remove application or gateway limits.
Check the rest of the upload path
PHP distinguishes upload_max_filesize from post_max_size; the latter must accommodate the entire multipart body. Application frameworks and multipart parsers also have their own limits. CDNs, gateways, and load balancers can reject an upload before it reaches Nginx, so check the deployed service's documented limit.
Timeouts are a separate dimension. client_body_timeout concerns gaps while receiving the client body. proxy_read_timeout and fastcgi_read_timeout concern gaps while reading an upstream response; they are not upload-duration limits. Increase only the timeout relevant to the observed failure.
FAQ
Why declare the limit when the default is sufficient?
An explicit value records the intended policy and makes overrides easier to review. Distribution-provided configuration may already override the built-in default.
Does the limit apply to GET requests?
It limits request bodies regardless of method. A normal GET without a body has no upload to limit, but the method itself does not exempt a body from the check.
What about multi-gigabyte files?
Use a design that supports interruption and retry, such as application-level chunking or direct object-storage uploads with scoped presigned URLs. Raising one limit does not address disk pressure, concurrent uploads, or application memory use.
Reference: client_max_body_size and related core directives.
Contact us
Join the community
to join the community
Try Guance
Start online and pay only for what you use.
Get startedChoose a Guance plan