Skip to content

413 Content Too Large — Meaning, Common Causes & How to Fix

413 4xx Client Error RFC 9110 §15.5.14

413 Content Too Large means: The request body is larger than the server is willing or able to process. Formerly 'Payload Too Large' / 'Request Entity Too Large'; RFC 9110 renamed it Content Too Large. The server may close the connection, and Retry-After can indicate when to retry. Client-error 4xx codes mean the request itself is the problem: malformed syntax, missing credentials, forbidden access, a nonexistent resource or a violated precondition. The server is telling the client what to change; retrying the identical request without a fix will reproduce the same error. In practice you will meet 413 when an upload exceeds nginx client_max_body_size or an api gateway limit; a json batch payload grows past the application's max request size; a waf or cdn enforces its own body-size ceiling before the origin sees it. On the client side, compress, split or stream the payload in chunks; check every hop's limit (CDN, LB, gateway, app) — the smallest one wins. On the server side, set explicit, documented body limits at each layer and return 413 with the limit in the body; align nginx/LB/app values to avoid confusing mismatches.

Advertisement
Ad slot · ref-top

When 413 happens

  • An upload exceeds nginx client_max_body_size or an API gateway limit
  • A JSON batch payload grows past the application's max request size
  • A WAF or CDN enforces its own body-size ceiling before the origin sees it

How to fix it

On the client

Compress, split or stream the payload in chunks; check every hop's limit (CDN, LB, gateway, app) — the smallest one wins.

On the server

Set explicit, documented body limits at each layer and return 413 with the limit in the body; align nginx/LB/app values to avoid confusing mismatches.

Should you retry?

Not retryable as-is: change the request (credentials, payload, URL) first.

Debugging steps

When 413 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Read the error body first — well-designed APIs name the offending field or missing credential. Then diff your actual request, headers included, against the documented contract. For this code specifically, check whether the most common trigger applies to your situation: an upload exceeds nginx client_max_body_size or an api gateway limit. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.

Notes & gotchas

Body limits are enforced at every hop — CDN, load balancer, gateway, web server, application — and the smallest limit wins; a 413 often comes from a layer your application code never sees.

Examples

Raw HTTP
HTTP/1.1 413 Content Too Large
Retry-After: 120
Content-Type: application/json
Content-Length: 119

{
  "error": "content_too_large",
  "message": "An upload exceeds nginx client_max_body_size or an API gateway limit"
}
curl
curl -i -X POST -H "Content-Type: application/json" --data-binary @big-payload.json https://api.example.com/v1/import
JavaScript (fetch)
const res = await fetch("https://api.example.com/v1/resource");
if (res.status === 413) {
  const problem = await res.json(); // read field-level details
  // fix the request (credentials, payload, URL) — identical retries keep failing
  throw new RequestError(problem);
}
Python (requests)
import requests

res = requests.get("https://api.example.com/v1/resource", timeout=10)
if res.status_code == 413:
    problem = res.json()  # field-level error details
    # correct the request before retrying — identical retries keep failing
    raise RequestProblem(problem)

Frequently asked questions

Why does nginx return 413 before my app runs?

client_max_body_size defaults to 1 MB and is enforced at the web-server layer. Raise it (and any LB/CDN limits) to match your application's needs.

Is 413 retryable?

Only after shrinking the payload or waiting out a Retry-After. Retrying the identical oversized body will fail identically.

Are 4xx errors always the client's fault?

By contract yes — the server asserts the request must change. In practice servers sometimes misuse 4xx for their own problems (e.g. 400 for internal validation bugs), so read the error body before blaming your client code.

Should I retry 4xx responses automatically?

Generally no: the server says the request must change. Exceptions are 408 (fresh connection), 425 (after handshake) and 429 (after Retry-After). Blind retries of 400/401/403/404 just burn quota.

Advertisement
Ad slot · ref-in-article

Try the JSON Validator

Check JSON syntax and locate errors by line and column.

Open tool →