Skip to content
4xx · client errorSent by Proxy | App | CDN

413Content Too Large

The request body is bigger than the server is willing to accept.

How you get a 413

A 5 MB upload arrives. The proxy accepts 1 MB at most, so it stops reading and the proxy sends 413. The app never sees the request, so its logs show nothing.

Who sends itProxy · App · CDN

  1. Browser
  2. CDN
  3. Proxy
  4. App
  5. DB

Typically the proxy, which enforces a body size limit before passing anything on. The app's own body parser and the CDN have limits too, and the smallest one in the chain wins.

In short

What a 413 Content Too Large means

A 413 Content Too Large means the body of the request, usually a file upload or a large JSON document, is bigger than some box is prepared to accept. Older software calls it Payload Too Large or Request Entity Too Large; the meaning is the same. Every hop has its own limit and the smallest one decides. The proxy is the usual sender: nginx allows 1 MB unless configured otherwise and rejects larger bodies without telling the application. If the request passes the proxy, the application's body parser may still refuse it with its own, often smaller, limit. Because the server can reject the request before the upload has finished, it may also just close the connection, and the browser then reports a network error with no status code.

Common causes of a 413

  1. 1The proxy's body size limit. In nginx it is client_max_body_size, 1 MB unless changed.

    How to check: nginx logs the rejection with the size the client announced.

    client intended to send too large body: 5242880 bytes
  2. 2The app framework's body parser has its own limit, often far smaller than the proxy's.

    How to check: The error comes in your API's format, not as the proxy's page. Check the parser's size option.

  3. 3A CDN, API gateway or hosting platform caps request size for your plan.

    How to check: The Server header names the product. Its documentation lists the cap.

  4. 4The client sends a file inline as base64 inside JSON, which makes it about a third larger.

    How to check: Compare the file's size on disk with the Content-Length of the request.

Retry or not?

Retry only after fixing the request

The same body will be refused again. Send less: compress it, split it into parts, or upload large files straight to object storage and send only a reference.

Headers that matter

Content-Length
Request header. The size the client announces; servers compare it with their limit before reading the body.
Expect: 100-continue
Request header. Asks the server to approve the headers first, so the client learns about a 413 before it uploads anything.
Retry-After
Only if the limit is temporary, which is rare.

In the real world

RFC vs real deployments

RFC 9110 renamed this code to Content Too Large. Earlier standards called it Payload Too Large and Request Entity Too Large, and nginx's error page still uses the oldest name. The RFC also lets the server close the connection so the client stops sending. When that happens mid-upload, browsers tend to show a connection error and the 413 is only visible in the proxy's log.

Seen in a real outage

Hard limits are easy to forget until something crosses them. Basecamp could suddenly save nothing in 2018, because an ID column reached 2,147,483,647, the largest value it could hold.

Your turn

Which code is it?

Photo uploads over about 1 MB fail with an nginx page saying “413 Request Entity Too Large”. Smaller ones work. The app has no log entries for the failures. What should you change?

413 questions

Who sends a 413?
Typically the proxy, such as nginx, which checks the body size before forwarding. The application's body parser, a CDN or an API gateway can also send it.
How do I fix 413 Request Entity Too Large in nginx?
Raise client_max_body_size for the server or location that receives uploads, then reload nginx. Check that the application behind it accepts the same size.
Is 413 Payload Too Large the same as Content Too Large?
Yes. The code is the same; only the name changed between versions of the HTTP standard.

Sources: RFC 9110: 413 Content Too Large (section 15.5.14) ↗ · nginx: client_max_body_size ↗ · Report a problem

Diagrams are our own simulations. All wording is original and paraphrases the linked sources.

Practise this in the DNS / HTTP track

Two-minute animated lessons, then boss fights from real outages. Free, no account needed.

Start the track