Maximum upload size is rarely controlled in one place. This reference shows where limits are enforced across web servers, application frameworks, reverse proxies, and serverless platforms, then gives you a practical checklist for changing and testing them safely.
Overview
An upload can be rejected before your application receives a single byte. A reverse proxy may enforce a request-body limit, the web server may apply another, PHP may reject the request based on its own settings, and the application framework may impose a parser or middleware limit. A hosting platform can add a final quota or timeout that you cannot change from application code.
The effective maximum is therefore the smallest applicable limit in the request path:
effective limit = the lowest limit enforced by the client, proxy, web server, runtime, framework, application, or hosting platform
Configuration names and defaults also change by version, distribution, hosting provider, and installed middleware. Treat the values below as a starting reference, not a substitute for the documentation and active configuration of your deployment.
| Layer | Common control | Units or behavior | Timeout controls to review |
|---|---|---|---|
| Nginx | client_max_body_size | Size suffixes such as m or g; a server or location can override broader settings. A commonly encountered default is 1 MB. | client_body_timeout, upstream connect/read timeouts |
| Apache HTTP Server | LimitRequestBody | Bytes. A value of 0 commonly means no directive-level limit, but modules, proxies, or the host may still impose one. | RequestReadTimeout, proxy timeout settings |
| PHP | upload_max_filesize and post_max_size | PHP shorthand values such as 2M or 8M. The POST limit must accommodate the complete multipart request, not only the file. | max_input_time, web-server request timeouts |
| Node.js and Express | Parser or upload middleware limits, such as limit | Depends on the parser or package. Node's HTTP server does not automatically provide a universal file-upload maximum. | Server request and socket timeouts; middleware-specific limits |
| Reverse proxies and gateways | Provider- or product-specific request-body quotas | May be fixed, plan-dependent, route-dependent, or unavailable for streaming requests. | Request, idle, connection, and upstream execution limits |
| Serverless platforms | Platform request and response quotas | Usually fixed or plan-dependent. The limit may apply before the function starts, so application configuration cannot raise it. | Maximum execution duration, payload processing time, and connection limits |
For a precise diagnosis, record the HTTP status, response body, server logs, and the largest request that succeeds. A 413 Payload Too Large response often indicates an intermediary or server limit, while an application-generated validation error usually means the request reached your code.
Checklist by scenario
Nginx in front of an application
- Find the active
serverandlocationblock for the upload route. - Set a deliberate limit, for example
client_max_body_size 100m;, at the narrowest appropriate scope. - Check whether an included configuration file or a more specific location overrides it.
- Review
client_body_timeoutand the proxy's upstream timeouts for slow but legitimate uploads. - Validate and reload the configuration, then test a file just below and just above the intended boundary.
Increasing the Nginx limit does not increase a PHP, Express, gateway, or serverless limit behind it. Keep the layers intentionally aligned, with enough allowance for multipart overhead where applicable.
Apache serving PHP
- Identify whether Apache is using PHP-FPM, a module, or a hosting control panel.
- Check
LimitRequestBodyin the virtual host, directory, and route configuration. - Inspect the active PHP configuration with an approved diagnostic method; do not assume the command-line PHP configuration is the same as the web SAPI configuration.
- Set both
upload_max_filesizeandpost_max_size. The latter should be larger than the file limit to allow for fields and multipart boundaries. - Check PHP's input time and the web server's request-read timeout if large uploads fail only on slow connections.
After changing PHP settings, restart or reload the relevant service when required. A browser refresh alone does not prove that the worker processes loaded the new configuration.
Node.js and Express
- Identify the upload package and parser in use, such as a multipart middleware, and read its limit option.
- Set an explicit file-size limit instead of relying on a package default.
- Distinguish the maximum size of one file from the maximum size of the complete request and from the maximum number of files.
- Handle the package's specific limit error and return a clear client response.
- Review server, load-balancer, and ingress timeouts for uploads that are streamed or processed asynchronously.
Express body-parser settings such as express.json({ limit: '1mb' }) affect JSON requests, not necessarily multipart file uploads. Configure the middleware that actually parses the upload format.
Reverse proxies, CDNs, and serverless functions
- Map the complete route: browser, CDN, edge proxy, ingress, web server, runtime, application, and storage service.
- Check the provider's current request-body, execution-time, and plan-specific quotas.
- Determine whether the platform buffers the request, streams it, or rejects it before invoking your code.
- If the direct upload path is too restrictive, consider a signed direct-to-storage upload or a resumable, chunked protocol.
- Test from the same public hostname and route used by real clients; an internal test can bypass the limiting layer.
For multipart testing, see How to Test File Upload APIs: A Multipart Form-Data Checklist. For pause, retry, and large-file designs, use the resumable uploads guide.
What to double-check
- Units: confirm whether a setting uses bytes, decimal megabytes, binary mebibytes, or a configuration suffix. Do not compare values until their units are normalized.
- Request versus file size: multipart fields, boundaries, headers, and metadata add overhead. A request limit equal to the exact file size can still reject the upload.
- Scope: check global, virtual-host, route, directory, and middleware settings. The most specific active rule often wins.
- HTTP method and content type: a JSON limit may not affect multipart data, and a route may treat PUT, POST, and resumable chunks differently.
- Timeouts: size is only one constraint. A large file may be permitted but fail because the connection is slow or an upstream worker times out.
- Storage and temporary space: PHP and other runtimes may write temporary upload data before application processing. Verify available disk space and cleanup behavior.
- Security validation: a larger limit increases resource exposure. Keep extension, MIME, signature, authentication, authorization, malware-scanning, and rate-limit controls in place.
- Observability: log the route, authenticated principal or request ID, size, duration, rejection layer, and reason without logging sensitive file contents.
When validating a public upload endpoint, also review the related cURL, Postman, and automated request testing guide. Browser behavior can add another constraint, so compare results with the browser file upload limits reference.
Common mistakes
- Changing only one layer: raising
client_max_body_sizewill not change PHP, middleware, hosting, or storage limits. - Using a zero or unlimited setting casually: an unlimited request body can enable memory, disk, CPU, and bandwidth exhaustion. Prefer a documented business limit.
- Testing only a small file: use boundary tests, including a file below the limit, one close to it, and one above it.
- Ignoring failed partial uploads: streamed or resumable designs need cleanup for abandoned temporary objects and incomplete multipart sessions.
- Confusing client validation with enforcement: an HTML
acceptattribute or JavaScript size check improves usability but is not a security boundary. - Assuming a framework default is stable: package upgrades can change parser behavior. Pin versions, inspect release notes, and keep the limit explicit in application configuration.
When to revisit
Recheck this reference before a seasonal traffic increase, after moving hosts, when changing CDN or reverse-proxy providers, and whenever an upload workflow changes from direct requests to chunked or signed storage uploads. Revisit it after major web-server, runtime, framework, or serverless-platform upgrades because defaults and quotas are version- and provider-dependent.
Keep a short upload-limit record with the route, intended maximum, unit, active settings at each layer, timeout values, last test date, and documentation links. Then run the same boundary test in staging and production after deployment. If the required file size exceeds a reliable synchronous request path, move to resumable uploads rather than raising every limit without review. For file type and delivery considerations, the web image format reference and Content-Disposition guide provide useful follow-up checks.
Final deployment checklist: identify every hop, normalize units, set explicit limits, align timeouts, test the public route at the boundary, inspect logs at the rejecting layer, verify temporary storage, and document the result for the next infrastructure change.