Skip to main content
Network & HTTP · Developer Error Resolution Lab

Fix Nginx Error: '413 Request Entity Too Large' on File Uploads

Increase Nginx client_max_body_size and framework upload limits to allow large file and payload transfers.

Triggered Error Message:

413 Request Entity Too Large: client intended to send too large body

Customize Solution for Your Environment
# /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf
http {
    client_max_body_size 50M;
    client_body_buffer_size 128k;
}

# Next.js Server Action / API Route Body Limit (next.config.js):
module.exports = {
  experimental: {
    serverActions: {
      bodySizeLimit: '50M',
    },
  },
};

Root Cause & Mechanism Analysis

Why does this error occur?

Nginx defaults to a 1MB max body limit (`client_max_body_size 1m`). Uploads exceeding 1MB are rejected before reaching application code.

Frequently Asked Questions

Do I also need to update my Node.js express/bodyParser limit?
Yes. In Express, configure `app.use(express.json({ limit: '50mb' }))` to match Nginx.
Browse All 35 Guides