413 Content Too Large

The HTTP 413 Content Too Large status code is a client error returned by the server when the request message body is larger than the server is willing to accept for processing.

Usage

When the 413 Content Too Large error message is received, the client is sending a request body too large for the server. A common example is when a client tries to send a file of an acceptable type and format but the file exceeds the size limit. Pictures, for instance, are often at an unnecessarily high resolution and are significantly smaller without impacting the intended use. Rather than take on the responsibility of modifying the image files, the server refuses the transfer and relies on the client to do the necessary processing.

In these situations, a client checks for file size allowance in advance of initiating the PUT by using the Expect: 100-continue header. The server will acknowledge and in response, the message body is sent or withheld.

The server optionally sends a Retry-After header in the response. If present, the client attempts the request again after a specified period or specified time and date. For example, if the client has exceeded an upload quota for the week, or large uploads are not allowed during peak hours, the server will suggest trying again at a more appropriate time.

If the situation occurs because the server is out of storage space then the server sends 507 instead.

The server includes the Connection: close header to terminate the connection, preventing the client from sending the message body.

SEO impact

Search engines like Google will not index a URL with a 413 response status. URLs previously indexed will be removed from search results.

Example

The client attempts to send a file and the server responds with 413 Content Too Large because there is heavy traffic at the moment. The server denies the request, closes the connection, and suggests the client try again after 30 minutes.

Request

PUT /docs HTTP/1.1
Host: www.example.re
Content-Type: application/pdf
Content-Length: 10000

Response

HTTP/1.1 413 Content Too Large
Retry-After: 1800
Connection: close
Content-Type: text/html
Content-Length: 188

<html>
  <head>
    <title>File Too Large</title>
  </head>
  <body>
   <p>Too much server traffic to accept the transfer
   at this time. Try again after 30 minutes.</p>
  </body>
</html>

How to fix

The error originates from whichever layer in the stack enforces a size limit first: web server, reverse proxy, CDN, or application framework. Identify the layer returning the 413 and adjust the limit there.

nginx: Set client_max_body_size in the http, server, or location block. A value of 0 disables the check entirely (not recommended in production). Restart nginx after changing the value.

Apache: Set LimitRequestBody in httpd.conf or .htaccess. The value is in bytes, so 10 MB is 10485760. Reload Apache to apply.

IIS: Edit the maxAllowedContentLength attribute in the web.config file under system.webServer > security > requestFiltering > requestLimits.

PHP: Adjust both upload_max_filesize and post_max_size in php.ini. The post_max_size value must be equal to or larger than upload_max_filesize.

Node.js / Express: Set the limit option in body-parser or Express's built-in JSON/URL-encoded middleware, e.g. express.json({ limit: '50mb' }).

Cloudflare: Free and Pro plans cap uploads at 100 MB, Business at 200 MB, Enterprise at 500 MB. Uploads exceeding these limits return 413 before reaching the origin. For large file uploads behind Cloudflare, bypass the proxy or use chunked upload strategies.

On the client side, compress or chunk large payloads before sending. For file uploads, implement multipart or resumable upload protocols to stay within server limits. Use the Expect: 100-continue mechanism to check whether the server will accept the payload size before transmitting the full body.

Code references

.NET

HttpStatusCode.RequestEntityTooLarge

Rust

http::StatusCode::PAYLOAD_TOO_LARGE

Rails

:payload_too_large
:request_entity_too_large

Go

http.StatusRequestEntityTooLarge

Symfony

Response::HTTP_REQUEST_ENTITY_TOO_LARGE

Python3.5+

http.HTTPStatus.REQUEST_ENTITY_TOO_LARGE

Java

java.net.HttpURLConnection.HTTP_ENTITY_TOO_LARGE

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_REQUEST_TOO_LONG

Angular

@angular/common/http/HttpStatusCode.PayloadTooLarge

Takeaway

The 413 Content Too Large status code is a client error returned when the message body is too large for the server to process. The connection is often closed, and the client receives a Retry-After header if the problem is temporary.

See also

Last updated: March 11, 2026