4xx client errorNot retryable as isLimit set by the server
413 Content Too Large
The request body is larger than the server is willing to process. RFC 9110 renamed it from "Payload Too Large", and nginx still says "Request Entity Too Large", its name from RFC 2616. A server that expects the limit to be temporary can add Retry-After.
Open Base64 See how much Base64 inflates a file.
Common causes
- nginx rejects bodies over
client_max_body_size, which defaults to 1 MB. - The framework's body parser has its own, smaller limit: Express's JSON parser defaults to 100 kB.
- The platform caps the request: a synchronous AWS Lambda invocation takes at most 6 MB.
- A file sent as Base64 inside JSON grows by a third, so a 4 MB image becomes about 5.3 MB of text.
How to fix it
- Find which layer answered. The body and the
Serverheader usually give it away: nginx's HTML page looks nothing like your API's JSON. - Raise the limit on every layer the request passes, not just the first: proxy, framework and platform.
- Send files as
multipart/form-dataor as raw bytes instead of Base64 in JSON. - For large uploads, go straight to object storage with a presigned URL, or split the file into chunks (S3 multipart upload, the tus protocol).
413 or 414?
413 is about the body. 414 URI Too Long is about the URL, usually a query string that grew too big; the fix there is to move the data into a POST body.
413 or 431?
431 Request Header Fields Too Large is the same kind of limit for headers, and nearly always means too many or too large cookies.
Example
HTTP/1.1 413 Request Entity Too Large Server: nginx Content-Type: text/html Connection: close <html> <head><title>413 Request Entity Too Large</title></head> <body> <center><h1>413 Request Entity Too Large</h1></center> <hr><center>nginx</center> </body> </html>
Defined in RFC 9110, section 15.5.14.