LIMIT_FILE_SIZE 🔌 API

Upload error: File too large (LIMIT_FILE_SIZE / file exceeds maximum upload size)

The uploaded file is larger than the limit set by the API, framework or server.

Seen on: REST API

Meaning

Limits exist at several layers: the app (Multer LIMIT_FILE_SIZE “File too large”, Laravel “may not be greater than 2048 kilobytes”), the language runtime (PHP upload_max_filesize / post_max_size), the web server (Nginx client_max_body_size → 413) and the provider (S3 single PUT 5 GB, many APIs 10–100 MB).

The smallest limit wins, so raising one layer isn’t enough if another is lower.

Common causes

  • File genuinely above the documented limit
  • Framework limit lower than the server limit (or vice versa)
  • Multipart overhead or base64 encoding (+33%) pushes it over
  • Proxy/CDN limit in front of the app

⚡ Quick fix

  1. Compress or resize before uploading
  2. Use the provider’s multipart/chunked or resumable upload for large files
  3. Raise the limit at every layer you control (app, PHP, web server, proxy)

Detailed fix by platform

Node.js

  1. const upload = multer({ limits: { fileSize: 20 * 1024 * 1024 } }); // 20 MB

PHP

  1. php
    ; php.ini
    upload_max_filesize = 20M
    post_max_size = 25M

Nginx

  1. client_max_body_size 25m;

How to diagnose

  1. Size — Actual file and request size
  2. Layers — App, runtime, web server, proxy limits
  3. Encoding — Is the file base64-encoded in JSON?

🧠 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.