Skip to main content
4xx Client Error

413 Payload Too Large

The request is larger than the server is willing or able to process.

Meaning & Description

The 413 Payload Too Large status code (formerly known as Request Entity Too Large) indicates that the server refuses to process a request because the request payload is larger than the server is willing or able to handle. This usually happens when a user attempts to upload a file that exceeds the server's configured maximum upload size. The server may close the connection to prevent the client from continuing the request.

Common Causes

  • File uploads exceeding the maximum permitted size configured in Nginx/Apache.
  • Framework-level body parser limits (e.g., Express.js `body-parser` default is usually 100kb).
  • Ingress controllers or API gateways blocking large payloads before they reach the application.

How to fix a 413 error

  1. Check your reverse proxy or web server settings (e.g., `client_max_body_size` in Nginx).
  2. Check your application framework's body parser configuration (e.g., Express `express.json({ limit: "50mb" })`).
  3. If the limit is intentional, compress the payload on the client or implement chunked/resumable file uploads.
  4. Check if a `Retry-After` header is present in the response.

Browser & SEO Behaviour

Browser Behavior

Browsers will display the response body (if any). If the connection is closed abruptly by the server, the browser may show a generic connection reset or network error.

SEO Impact

No direct SEO impact, as search engines rarely perform POST requests or upload files.

CDN Behavior

CDNs often enforce their own maximum payload sizes (e.g., Cloudflare limits free tier uploads to 100MB). If exceeded, the CDN returns a 413 without forwarding to the origin.

Code Examples

HTTP
HTTP/1.1 413 Payload Too Large
Connection: close
Content-Type: application/json

{
  "error": "File exceeds maximum allowed size of 5MB."
}
Node.js (Express)
const express = require("express");
const app = express();

// Set a payload limit; Express returns 413 automatically if exceeded
app.use(express.json({ limit: "5mb" }));

app.post("/data", (req, res) => {
  res.send("Payload accepted");
});
Python (FastAPI)
from fastapi import FastAPI, Request, HTTPException

app = FastAPI()
MAX_SIZE = 5 * 1024 * 1024  # 5MB

@app.post("/upload")
async def upload(request: Request):
    body = await request.body()
    if len(body) > MAX_SIZE:
        raise HTTPException(status_code=413, detail="Payload Too Large")
    return {"message": "Success"}
Go (net/http)
func handler(w http.ResponseWriter, r *http.Request) {
    // Limit body to 5MB. If exceeded, returns 413 automatically by some middlewares or manual check
    r.Body = http.MaxBytesReader(w, r.Body, 5<<20)
    err := r.ParseForm()
    if err != nil {
        http.Error(w, "Payload Too Large", http.StatusRequestEntityTooLarge)
        return
    }
    w.WriteHeader(http.StatusOK)
}
C# (ASP.NET Core)
[HttpPost("upload")]
[RequestSizeLimit(5_000_000)] // 5MB limit
public IActionResult Upload()
{
    return Ok();
}
cURL
# Attempting to send a massive file
curl -X POST -F "file=@huge_video.mp4" https://api.example.com/upload

Raw HTTP Response Example

HTTP Response
HTTP/1.1 413 Payload Too Large
Date: Wed, 21 Oct 2026 07:28:00 GMT
Connection: close
Content-Type: application/json

{"error": "Max upload size is 10MB"}

Real-world Examples

Cloudflare: Returns a 413 status code if a client attempts to upload a file larger than the maximum permitted by the domain's plan (e.g., 100MB for Free tier).
NGINX: Returns 413 if the request body exceeds the `client_max_body_size` directive.
Discord API: Returns 413 when attempting to upload attachments larger than the allowed limit for the guild or user tier.

Frequently Asked Questions

How do I fix a 413 Payload Too Large error in Nginx?

You need to increase the `client_max_body_size` directive in your `nginx.conf` or virtual host configuration block. For example: `client_max_body_size 50M;`

Does a 413 error happen only with file uploads?

No. While common with files, a 413 can occur with any large payload, such as a massive JSON array in a POST request or a huge base64-encoded string.

How can clients handle 413 errors gracefully?

Clients should validate file sizes locally before attempting an upload. If a 413 occurs, inform the user of the maximum allowed size.

Can I include a Retry-After header with a 413?

Yes, if the condition is temporary (e.g., the server is temporarily out of space), the server can include a `Retry-After` header to indicate when the client may try again. However, usually, a 413 means the payload is permanently too large.

Did You Know?

The status code was originally named "Request Entity Too Large" in older RFCs but was renamed to "Payload Too Large" in RFC 7231 to be more accurate.

If the server closes the connection during the request to save bandwidth, some browsers might display a "Connection Reset" error instead of parsing the 413 response.

Developer Tips

  • Implement client-side validation to check file sizes before initiating an upload. This saves bandwidth and provides a faster, better user experience.
  • For very large uploads, consider implementing a chunked upload mechanism (e.g., using Tus protocol) or presigned URLs directly to cloud storage (like S3) to bypass your application server.
  • Always ensure your reverse proxy (like Nginx), API gateway, and application framework have their max body size limits aligned so the error is caught at the earliest possible stage.

Interview Questions

These are questions you might face in a backend or API design interview that touch on HTTP 413.

Where in a modern web stack can a 413 Payload Too Large error originate?

It can originate at multiple layers: a CDN (like Cloudflare), an ingress controller/load balancer, a web server (like Nginx `client_max_body_size`), or the application framework itself (like Express `body-parser` limits).

How would you architect a system to handle 5GB video uploads without hitting 413 errors on your web server?

I would bypass the web server for the actual upload by generating a Presigned URL (e.g., AWS S3) from the backend. The client uploads directly to object storage using that URL, and then notifies the backend once the upload is complete.

Common Interview Mistakes

  • Assuming a 413 is only for file uploads; it applies to any HTTP request body, including large JSON payloads.
  • Not realizing that proxy servers (like Nginx) often enforce limits independently of the application code.
  • Confusing 413 with 414 URI Too Long. 413 is for the body payload; 414 is for the URL length.