Open each layer in order
Set client_max_body_size in the http, server or location block, then run nginx -t and reload. A config change without reload does nothing.
In PHP, change upload_max_filesize and post_max_size together. The latter must exceed the former or large files still fail. Restart php-fpm; reloading Nginx is not enough.
Do not forget the front layer
CDNs, WAFs and cloud load balancers often have their own body size limits that need adjusting in the console.
Frameworks may impose their own request size limits, as do object storage SDKs with chunk thresholds.
Large files should be chunked
For files in the hundreds of megabytes, raising limits is the wrong fix: a single request ties up memory and timeouts, and an interrupted upload restarts from zero.
Use multipart upload or direct-to-object-storage with server-issued credentials. Both are more stable and cheaper to operate.
FAQ
I changed Nginx and still get 413. Why?
Check who returns the error page. If it is styled by your application, the request already reached the app, so the limit is in PHP or the framework.
How large should post_max_size be?
Larger than upload_max_filesize, with headroom for other form fields.
Can 413 turn into 502?
Yes. After raising body limits, large uploads may hit execution timeouts, producing 504 instead. Tune both.
Related questions
Further reading
Sources & References
The following are public sources. Always check the latest requirements on the official authority or platform page.
