Skip to content
4134xx · Client errorThe client seems to have erred. RFC 9110 §15.5

HTTP 413 Content Too Large: what it means and how to fix it

Meaning

HTTP 413 means a server or proxy refused the request because its body is bigger than the limit it accepts. Shrink the body or raise that hop's limit.

When a proxy returns 413, find the hop first

Somewhere between you and the application, one hop has a ceiling on request bodies, and yours went over it. RFC 9110 section 15.5.14 names the code “413 (Content Too Large)” and allows the server either to end the request or to close the connection. If the limit is only temporary, the server SHOULD add a Retry-After header. Most limits are not temporary, so retrying the same body changes nothing.

Three names for one code

The reason phrase depends on which RFC the software was written against. RFC 2616 called 413 “Request Entity Too Large”, RFC 7231 renamed it “Payload Too Large”, and RFC 9110 settled on “Content Too Large”. All three are still in circulation. We printed the built-in phrase from three runtimes and captured the status line from two servers:

Software Phrase it uses for 413 How we read it
Python 3.15.0 Content Too Large http.HTTPStatus(413).phrase
Squid 6.13 Content Too Large status line of a captured response
Node.js 24.2.0 Payload Too Large http.STATUS_CODES[413]
Go 1.24.4 Request Entity Too Large http.StatusText(413)
Apache httpd 2.4.67 Request Entity Too Large status line of a captured response

Match on the number. RFC 9112 section 4 says a client SHOULD ignore the reason phrase, because intermediaries may rewrite it and HTTP/2 does not carry one at all.

Reproduce it with curl

This server accepts bodies up to 1 MiB and refuses anything larger. It checks Content-Length twice: once when the client asks for permission with Expect: 100-continue, and again when the body arrives without asking.

# server413.py, Python 3.15.0, standard library only
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer

MAX_BODY = 1024 * 1024  # 1 MiB

class Upload(BaseHTTPRequestHandler):
    protocol_version = "HTTP/1.1"

    def too_large(self):
        length = int(self.headers.get("Content-Length", 0))
        if length <= MAX_BODY:
            return False
        self.send_response(413)
        self.send_header("Content-Type", "text/plain")
        msg = f"limit is {MAX_BODY} bytes\n".encode()
        self.send_header("Content-Length", str(len(msg)))
        self.send_header("Connection", "close")
        self.end_headers()
        self.wfile.write(msg)
        self.close_connection = True
        return True

    def handle_expect_100(self):
        if self.too_large():
            return False
        return super().handle_expect_100()

    def do_POST(self):
        if self.too_large():
            return
        body = self.rfile.read(int(self.headers.get("Content-Length", 0)))
        msg = f"stored {len(body)} bytes\n".encode()
        self.send_response(200)
        self.send_header("Content-Length", str(len(msg)))
        self.end_headers()
        self.wfile.write(msg)

ThreadingHTTPServer(("127.0.0.1", 8413), Upload).serve_forever()

Sending a 2 MiB file with curl 8.23.0 produced this, unedited:

$ head -c 2097152 /dev/urandom > big.bin
$ curl -sv --data-binary @big.bin http://127.0.0.1:8413/upload
*   Trying 127.0.0.1:8413...
* Established connection to 127.0.0.1 (127.0.0.1 port 8413) from 127.0.0.1 port 62143
* using HTTP/1.x
> POST /upload HTTP/1.1
> Host: 127.0.0.1:8413
> User-Agent: curl/8.23.0
> Accept: */*
> Content-Length: 2097152
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
>
< HTTP/1.1 413 Content Too Large
< Server: BaseHTTP Python/3.15.0
< Date: Wed, 21 Oct 2026 19:53:28 GMT
< Content-Type: text/plain
< Content-Length: 23
< Connection: close
<
{ [23 bytes data]
* we are done reading and this is set to close, stop send
* abort upload
* shutting down connection #0
limit is 1048576 bytes

Expect: 100-continue decides how much you upload for nothing

curl added Expect: 100-continue on its own. In our runs the cut-off was exact: a 1,048,577-byte body got the header and a 1,048,576-byte body did not, in both curl 8.23.0 and the curl 8.7.1 that ships with macOS. Because the server above answers that check with 413, curl reported size_upload of 0 in three runs out of three. The body never left the machine.

Suppress the header with -H 'Expect:' and the picture changes. Over six loopback runs, curl had already pushed between 720,737 and 908,477 bytes of the 2 MiB file into the socket before it read the refusal. Python’s requests 2.32.3 and httpx 0.27.2, the clients covered in Using proxies in Python, sent no Expect header at all for the same body (we captured their raw request bytes), so they always stream first and learn about the limit afterwards. Both still surfaced the 413 cleanly, even with a 32 MiB body. Through a proxy that bills per GB, check whether upload traffic counts toward your bill before letting a retry loop resend a body that can never fit.

When a proxy returns 413, find the hop first

A proxy can enforce its own limit, or it can relay one from the origin. The headers tell you which. With Squid’s request_body_max_size set to 1 MB, the refusal carried Squid’s own identity:

< HTTP/1.1 413 Content Too Large
< Server: squid/6.13
< X-Squid-Error: ERR_TOO_BIG 0
< Via: 1.1 proxy-host (squid/6.13)
< Connection: close

When the Python origin refused and Squid only relayed it, the response kept Server: BaseHTTP Python/3.15.0 and gained a Via header. (The proxy’s hostname is masked in both captures.) Squid’s documented default is no body limit at all, so a Squid 413 usually means somebody configured one. The same reading works for the other usual suspects:

Hop Setting Documented default
nginx client_max_body_size 1m
Apache httpd 2.4.54 and later LimitRequestBody 1073741824 bytes (unlimited in 2.4.53 and earlier)
Squid request_body_max_size No limit
Cloudflare, Free and Pro plans Maximum Upload Size 100 MB
Cloudflare, Business plan Maximum Upload Size 200 MB

The curl proxy guide shows how to put -v output like this side by side for a direct and a proxied request, and 403 vs 407 vs 429 covers the codes a proxy is more likely to send.

Causes and fixes

Cause How to confirm it What to change
Body over the origin’s limit Server names the origin’s software; the error page is the origin’s Split the upload, use the API’s chunked or resumable upload, or ask the operator to raise the limit
Limit on your forward proxy The proxy’s own Server header, or X-Squid-Error: ERR_TOO_BIG Raise request_body_max_size, or send uploads direct with NO_PROXY
CDN upload cap Server: cloudflare on the 413 Keep each request under the plan’s cap, or upload straight to storage
Batch request grew too large The same endpoint accepts smaller batches Send fewer records per request
Client sends a larger body than intended Content-Length in curl -v is bigger than the payload you meant Fix the serialisation; a file appended twice or an unplanned base64 step inflates it

Whatever the client, set retries on 413 to zero unless the response carries Retry-After. A body that did not fit once will not fit on the next exit IP either.

Frequently asked questions

Is 413 the same as Request Entity Too Large and Payload Too Large?
Yes. They are names for the same code in older RFCs; match on the number 413.
Should a scraper retry a 413?
Not with the same body. Send fewer records or a smaller file unless the response includes Retry-After.

Sources

  1. RFC 9110 section 15.5.14: 413 Content Too Large
  2. nginx documentation: client_max_body_size

All terms, A to Z