413 🌐 HTTP

HTTP 413 Content Too Large (Request Entity Too Large)

The request body is bigger than the server is willing to accept — usually a file upload over the configured limit.

Seen on: Nginx PHP Node.js Apache

Meaning

Every layer between the client and your code has its own maximum body size: CDN, load balancer, web server and language runtime. A 413 comes from whichever layer has the smallest limit. Nginx’s default client_max_body_size is only 1 MB.

Common causes

  • Nginx client_max_body_size (default 1m) too small
  • PHP upload_max_filesize / post_max_size limits
  • Apache LimitRequestBody
  • Framework body-parser limits (Express json({ limit }) default 100kb)
  • CDN/load balancer limits (Cloudflare Free: 100 MB, API gateways often 10 MB)

⚡ Quick fix

  1. Raise client_max_body_size in Nginx and reload
  2. Raise upload_max_filesize and post_max_size in php.ini (post ≥ upload)
  3. Raise the framework body-parser limit
  4. For very large files, upload directly to object storage with pre-signed URLs

Detailed fix by platform

Nginx

  1. In http, server or location:
    nginx
    client_max_body_size 50M;
  2. Run sudo nginx -t && sudo systemctl reload nginx.

PHP

  1. php.ini (or .user.ini on shared hosting):
    ini
    upload_max_filesize = 50M
    post_max_size = 55M
    memory_limit = 256M
  2. Restart PHP-FPM. Note: when PHP’s limit is exceeded, $_POST and $_FILES are silently empty rather than a 413.

Node.js

  1. Express:
    javascript
    app.use(express.json({ limit: '10mb' }));
    app.use(express.urlencoded({ extended: true, limit: '10mb' }));

Apache

  1. Set LimitRequestBody 52428800 (bytes) in the vhost or .htaccess.

How to diagnose

  1. Size — How large is the request body?
  2. Response origin — Which layer answered — check the Server header and HTML body of the 413
  3. Limits — CDN → load balancer → web server → runtime → framework

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.