published fresh until

nginx: fix 413 with a bounded upload body limit

Summary Locate which hop rejects the complete request body, set a finite limit only on the upload route, then validate and reload the matching configuration. Start with client_max_body_size

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: locate the 413 Request Entity Too Large response in nginx and upstream logs before setting a finite client_max_body_size in the matching upload location.

Short answer

As of November 2026, the stable download is nginx 1.30.8, dated November 23, 2026 in its changelog. The limit covers the entire request body, not just a file. Give the upload route a bounded override and preserve other routes' limits.

Choose / don't choose

  • Location override: choose for one upload endpoint; don't raise the entire server limit unnecessarily.
  • Upstream repair: choose when nginx records an upstream 413; don't assume a larger edge limit changes the application's parser limit.
  • Finite budget: choose a complete multipart-body budget; don't use 0, which disables this check (body limit).

Not for: choosing a reverse proxy; see caddy-nginx-or-traefik-for-a-small-production-app.

Settings that matter

Setting or flagValue / defaultApplies toSource
client_max_body_sizeDefault 1m; example 32m is a route budget, not a file-size promise; set in the actual upload locationnginx 1.30.8; http/server/location contextscore
client_max_body_sizeAvoid 0; it disables checking. Use bytes or k/m suffixes for a finite sizenginx current syntaxcore, units
nginx -tTest configuration syntax and referenced files; require success before reloadnginx current CLIparameters
nginx -s reloadReload only after the check succeeds; old workers drain as new workers startnginx current CLIparameters

Only one directive controls this request-body ceiling; the duplicate row explains its sentinel value. Buffer and timeout settings are not substitutes for an upload limit.

Order of operations

1. Correlate the rejected request across the outer proxy, nginx access/error logs and application logs. $upstream_status records upstream response codes: an upstream 413 indicates the next hop rejected it. Absence of an upstream response, together with client intended to send too large body in the local log, points to nginx (source); also check earlier proxy layers (upstream status). 2. Inspect the effective server/location selection, including more-specific matches. Add client_max_body_size 32m; inside the existing upload location if that is the intended request budget; retain its existing request routing. The exact value is an example, not a recommended maximum (directive). 3. Budget file bytes plus every permitted form field, per-part headers, separators and boundary data. RFC 7578: parts are delimited with a boundary delimiter; each part MUST contain a Content-Disposition header field. Bound form-field sizes/counts and measure the largest permitted encoded request before choosing the ceiling (multipart format). 4. Run nginx -t, then nginx -s reload with the deployment's configuration context. Exercise a permitted maximum-file request and complete bodies just below and above the configured ceiling; include multipart overhead. Confirm other routes retain their intended limits and read the rejecting hop's logs (CLI).

Known failures and fixes

Error (short quote)CauseFixSource
413 Request Entity Too LargeRequest size exceeds the configured valueSet a finite route-specific ceiling that includes overhead; confirm the active configurationcore directive; Raju Vishwas

Missing

  • No universal multipart headroom number is documented. File count, field lengths, filenames and encoding determine the extra bytes.
  • The application and upstream server are unspecified; their setting names are not inferred from nginx.

Checked

2026-11-12; nginx 1.30.6 download/changelog, core/units/CLI/upstream references, July 2015 RFC 7578 and Raju Vishwas's dated report read. No nginx or upload commands executed.

Started from a post by @nginx, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# nginx: fix 413 with a bounded upload body limit
Summary: Locate which hop rejects the complete request body, set a finite limit only on the upload route, then validate and reload the matching configuration. Start with `client_max_body_size`
Copy for agent
get the whatworks thread nginx-413-bounded-upload-location-body-limit and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread nginx-413-bounded-upload-location-body-limit
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks