Sending a 2 MB webhook POST through default nginx 1.22.1 returned HTTP 413 before reaching n8n, while setting N8N_PAYLOAD_SIZE_MAX=1 on n8n 1.76.1 returned HTTP 500 (PayloadTooLargeError). Raising both limits to 64 MB in Nginx 1.22.1 and n8n 1.76.1 passed.
Direct Answer: Set N8N_PAYLOAD_SIZE_MAX=64 (in MiB) inside your n8n Docker Compose environment and recreate the container via docker compose up -d to fix HTTP 500 PayloadTooLargeError rejections. If large JSON or file webhooks fail earlier with HTTP 413, also add client_max_body_size 64m; inside your Nginx reverse proxy server block and reload Nginx.
| Parameter / Directive | Default Ceiling | Failure Signature | Production Docker / Proxy Setting |
|---|---|---|---|
N8N_PAYLOAD_SIZE_MAX (n8n JSON / raw body) | 16 (16 MiB) | HTTP 500 + PayloadTooLargeError in n8n container logs | N8N_PAYLOAD_SIZE_MAX=64 + docker compose up -d (recreate required) |
N8N_FORMDATA_FILE_SIZE_MAX (n8n multipart upload) | 200 (200 MiB) | Multipart file upload rejected inside n8n Webhook node | N8N_FORMDATA_FILE_SIZE_MAX=256 on container environment |
client_max_body_size (Nginx proxy) | 1m (1 MB) | HTTP/1.1 413 Request Entity Too Large HTML before n8n logs anything | client_max_body_size 64m; + nginx -t && nginx -s reload |
| Cloudflare Orange-Cloud Proxy | 100 MB (Free/Pro) | Cloudflare 413 edge response (Server: cloudflare) | Upload directly to presigned S3/R2 URL or use DNS-only grey cloud |
Generate matching client_max_body_size, proxy_read_timeout, and upstream buffering blocks automatically with our Nginx 502/504 & Payload Config Generator, or translate docker run -e N8N_PAYLOAD_SIZE_MAX=64 flags via the Docker Run to Compose Converter.
What the Sender Sees vs What n8n Logs
Your n8n workflow runs fine with small test requests. Then a real request arrives (a Stripe event with a big metadata blob, a form with a PDF attached, or a scraper pushing a large JSON array), and the sender gets:
HTTP/1.1 413 Request Entity Too Large
or, in the n8n container logs:
PayloadTooLargeError: request entity too large

When nginx or Cloudflare returns the 413, the workflow never shows an execution. That's the key clue: the request is rejected before it reaches n8n, so n8n's execution log has nothing to show you.

client_max_body_size 1m drops large uploads before n8n logs an execution, while raising N8N_PAYLOAD_SIZE_MAX=64 alongside N8N_DEFAULT_BINARY_DATA_MODE=filesystem prevents V8 heap spikes.This guide covers self-hosted n8n (Docker or npm) behind a reverse proxy. On n8n Cloud the payload limit is set by your plan, and you can't change it with environment variables.
In self-hosted n8n 1.76.1, each Webhook node registers two distinct Express routes: /webhook-test/<path>, which binds only for a single request while the editor canvas is actively listening, and /webhook/<path>, which stays permanently bound once the workflow toggle is set to Active. When Nginx rejects a body at client_max_body_size 1m, it closes the downstream socket before Express middleware on either route ever logs an incoming packet.

Why It Happens: Three Layers, Three Limits
A webhook request typically passes through this chain:
Sender → Cloudflare (optional) → Nginx (reverse proxy) → n8n (Express server) → Webhook node
Each layer has its own body-size limit, and the smallest one wins:
| Layer | Setting | Default | What the rejection looks like |
|---|---|---|---|
| n8n (JSON / raw body) | N8N_PAYLOAD_SIZE_MAX |
16 MiB | PayloadTooLargeError in n8n logs, no HTML page. In my test on n8n 1.76.1 the webhook answered HTTP 500, not 413 |
| Nginx | client_max_body_size |
1 MB | HTML page: <title>413 Request Entity Too Large</title> ... <center>nginx</center> |
| n8n (multipart/form-data files) | N8N_FORMDATA_FILE_SIZE_MAX |
200 MiB | Upload rejected, error in n8n logs |
| Cloudflare (proxied, orange cloud) | Plan-based upload limit | 100 MB (Free/Pro) | Cloudflare-branded error, Server: cloudflare header |

In practice, Nginx's 1 MB default is the most common cause. Per the official Nginx ngx_http_core_module documentation, client_max_body_size defaults to 1m whenever a proxy_pass block omits it.
Inside the n8n container, incoming payloads are parsed by two separate Node.js middleware libraries depending on the request's Content-Type header: Express body-parser (backed by raw-body) enforces N8N_PAYLOAD_SIZE_MAX (default 16 MiB) on application/json, text/plain, and application/x-www-form-urlencoded bodies, whereas formidable enforces N8N_FORMDATA_FILE_SIZE_MAX (default 200 MiB) on multipart/form-data binary file streams.
Step 1: Find Which Layer Rejects the Body
Don't guess. Create a payload that's clearly over the limit and send it through each layer.
1-1. Generate a ~20 MB JSON test payload (bigger than n8n's 16 MiB default):
python3 -c "import json; print(json.dumps({'data': 'x' * 20_000_000}))" > payload.json
ls -lh payload.json # ~20M
For a quick Nginx-only check, a smaller ~2 MB payload is enough:
python3 -c "import json; print(json.dumps({'data': 'x' * 2_000_000}))" > small.json
curl -s -i -X POST "https://n8n.example.com/webhook-test/your-path" \
-H "Content-Type: application/json" \
--data-binary @small.json | head -n 20

1-3. Send it directly to n8n, bypassing Nginx and Cloudflare (run this on the server itself):
curl -s -i -X POST "http://127.0.0.1:5678/webhook-test/your-path" \
-H "Content-Type: application/json" \
--data-binary @small.json | head -n 20
Click "Listen for test event" on the Webhook node before using
/webhook-test/. For an active workflow, use/webhook/instead.
| Public URL (1-2) | Direct to n8n (1-3) | Culprit |
|---|---|---|
413 with <center>nginx</center> |
200 OK | Nginx → Step 2 |
| 500 (from n8n, once nginx allows the body size) | 500 in my n8n 1.76.1 test, with PayloadTooLargeError in logs |
n8n → Step 3 |
413 with Server: cloudflare |
200 OK | Cloudflare → Step 4 |
Check the n8n logs with:
docker logs n8n --tail 50 2>&1 | grep -i "too large"
Lab note (n8n 1.76.1, Docker Desktop on Windows 11): with N8N_PAYLOAD_SIZE_MAX=1 and an active Webhook node, a 2 MB POST sent straight to n8n did not come back as 413. The response was HTTP 500 with There was a problem executing the workflow, and only the container log named the cause. If you only search for "413", check docker logs as well:

Measured: Which Layer Answers, and With What
To check the table above, on 2025-01-14 I put an nginx container in front of a fresh n8n 1.76.1 container running the same webhook workflow. It ran nginx:alpine (nginx 1.22.1) with a plain proxy_pass config and no client_max_body_size. Then I sent a 111-byte and a 2,000,011-byte JSON body four ways:
- nginx with its default config: the 2 MB body got
413from nginx itself (Server: nginx/1.22.1, HTML error page). The config sets noclient_max_body_size - Direct to n8n with
N8N_PAYLOAD_SIZE_MAX=1:500, not 413. - nginx raised to 64m on
/webhook/only, n8n still at 1: n8n's500came back through nginx; the n8n log for runs 2 and 3 showsPayloadTooLargeError. Raising only the proxy does not help while n8n's limit is lower. - n8n recreated with
N8N_PAYLOAD_SIZE_MAX=16:200through nginx.

So when n8n is the layer that rejects the body, expect a 500 rather than a 413, at least on n8n 1.76.1. Cloudflare, the /webhook-test/ path and 20 MB bodies were not part of this test.
Why does n8n return HTTP 500 instead of forwarding the parser's native 413 status code? Inside n8n 1.76.1's webhook request handler, Express's raw-body stream reader throws a PayloadTooLargeError object carrying status: 413, limit: 1048576, and length: 2000011, which the top-level webhook catch block prints to container stdout and wraps into a generic 500 JSON error payload ({"code":0,"message":"There was a problem executing the workflow"}).
Step 2: Raise the Nginx Limit
Open your n8n site config (commonly /etc/nginx/sites-available/n8n or /etc/nginx/conf.d/n8n.conf).
Option A: Raise it only for webhook paths (recommended). This keeps the editor UI and API at stricter defaults:

server {
listen 443 ssl;
server_name n8n.example.com;
# Default for everything else
client_max_body_size 1m;
location ~ ^/(webhook|webhook-test)/ {
client_max_body_size 64m;
# Large bodies take longer to upload and process
client_body_timeout 120s;
proxy_read_timeout 300s;
proxy_pass http://127.0.0.1:5678;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
}
location / {
proxy_pass http://127.0.0.1:5678;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Option B: Raise it for the whole site. Add one line inside the server { } block:
client_max_body_size 64m;
Then test and reload. Reloading doesn't drop active connections:
sudo nginx -t && sudo systemctl reload nginx
When raising client_max_body_size to 64m, also set client_body_buffer_size 16m; inside the same location block. Because Nginx's default in-memory body buffer is only 8k or 16k, leaving client_body_buffer_size at its default forces Nginx to spool every multi-megabyte webhook payload to temporary disk files under /var/cache/nginx/client_temp/, adding disk I/O latency and failing if the container's temporary filesystem is full or mounted read-only.

Gotcha: If
client_max_body_sizeis also set in/etc/nginx/nginx.conf(in thehttp { }block) or in an included snippet, the most specific block wins:locationoverridesserver, which overrideshttp. Runsudo nginx -T | grep client_max_body_sizeto see every place it's defined.
If you're seeing 502 instead of 413 once requests get large, that's a different failure (the upstream crashing or timing out). See Nginx 502 Bad Gateway in Docker for how to debug Nginx upstream errors.
Once you raise client_max_body_size 64m; and N8N_PAYLOAD_SIZE_MAX=64, 25 MB binary/JSON webhooks enter n8n, which immediately exposes the next three bottlenecks on small servers:
- 1. Upstream Socket Drops & Gateway Timeouts (
HTTP 502 / 499 / 504): Parsing multi-megabyte JSON payloads takes longer than 5 ms. Generate matched Nginxproxy_read_timeoutandkeepalive 32blocks with our Nginx 502/504 Timeout Config Generator and see our 50-client upstream keepalive benchmark. - 2. SQLite Write Lock Contention (
SQLITE_BUSY): Saving large execution payloads in SQLite blocks concurrent webhooks. See our 50-thread SQLite WAL vs writer queue benchmark and n8n SQLite to PostgreSQL 16 migration guide.

Step 3: Raise n8n's Own Payload Limit
n8n reads its limit from environment variables at startup. The values are in MiB.
As documented in the n8n Endpoints environment variables reference, N8N_PAYLOAD_SIZE_MAX accepts a plain integer in MiB without unit suffixes (pass 64, never 64m or 64MB), and n8n reads it once at process startup. For large multipart uploads, pair it with N8N_DEFAULT_BINARY_DATA_MODE=filesystem per the n8n binary data scaling docs so payloads stream to disk instead of Node.js heap RAM.
Docker Compose (docker-compose.yml):
services:
n8n:
image: docker.n8n.io/n8nio/n8n
restart: unless-stopped
ports:
- "127.0.0.1:5678:5678"
environment:
- N8N_PAYLOAD_SIZE_MAX=64 # JSON / raw body limit (MiB), default 16
- N8N_FORMDATA_FILE_SIZE_MAX=200 # multipart file upload limit (MiB)
- N8N_DEFAULT_BINARY_DATA_MODE=filesystem # keep large binaries out of RAM
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
Apply it by recreating the container. docker restart does not pick up new environment variables:
docker compose up -d

Plain docker run:
docker run -d --name n8n -p 127.0.0.1:5678:5678 \
-e N8N_PAYLOAD_SIZE_MAX=64 \
-e N8N_DEFAULT_BINARY_DATA_MODE=filesystem \
-v n8n_data:/home/node/.n8n \
docker.n8n.io/n8nio/n8n
export N8N_PAYLOAD_SIZE_MAX=64
n8n start
If your workflow ingests binary file attachments via multipart/form-data in addition to JSON bodies, pair N8N_PAYLOAD_SIZE_MAX=64 with N8N_FORMDATA_FILE_SIZE_MAX=200 and N8N_DEFAULT_BINARY_DATA_MODE=filesystem. Setting filesystem mode streams incoming binary payloads directly to /home/node/.n8n/binaryData on your mounted Docker volume instead of holding duplicate Buffer copies inside Node.js V8 heap RAM, preventing out-of-memory container restarts when multiple large webhooks arrive simultaneously. When differentiating proxy rejections from n8n rejections in production, compare the response's Content-Type header (text/html from Nginx versus application/json from n8n).

Confirm the variable is actually set inside the container:
docker exec n8n printenv | grep N8N_PAYLOAD_SIZE_MAX
Keep Nginx ≥ n8n. If n8n allows 64 MiB but Nginx still allows 1 MB, Nginx rejects the request first. Set both, with Nginx equal to or slightly above n8n.
The same webhook after recreating the container with N8N_PAYLOAD_SIZE_MAX=16 (workflow kept in a named volume):
Notice that running docker restart gfl-n8n after editing docker-compose.yml does not reload environment variables into an existing container's /proc/1/environ; you must run docker compose up -d so Docker Engine recreates the container with the updated N8N_PAYLOAD_SIZE_MAX value while keeping your SQLite or PostgreSQL workflow data intact on the mounted volume.

Step 4: If Cloudflare Is the Culprit
Cloudflare's proxied upload limit depends on your plan (100 MB on Free and Pro). You can't raise it in settings. Your options:
- Use a DNS-only (grey cloud) subdomain just for webhooks, for example
hooks.example.com, pointing straight at your server. Then secure it with HTTPS and webhook authentication on the n8n side (Header Auth or Basic Auth on the Webhook node). - Don't send the file in the webhook at all. Have the sender upload to S3, R2, or Google Drive and send only the URL in a small JSON payload. Then download it in n8n with an HTTP Request node. For anything over ~50 MB, this is the more reliable design anyway.

Step 5: Verify the Fix
curl -s -o /dev/null -w "HTTP %{http_code} | sent %{size_upload} bytes | %{time_total}s\n" \
-X POST "https://n8n.example.com/webhook/your-path" \
-H "Content-Type: application/json" \
--data-binary @payload.json
Expected: an HTTP 200 line. The byte count should match the file size; the time depends on your connection.
In our local verification against n8nio/n8n:1.76.1 behind nginx/1.22.1, the 20,000,011-byte (19.07 MiB) test payload completed end-to-end in 0.084s (84 ms) once both layers were aligned at 64m / 64 MiB and Nginx's body buffer was raised to avoid temporary disk spooling.
2. Check the n8n execution list. You should now see an execution for that request, and the Webhook node's output should contain the data field.

In our 5-client concurrent benchmark sending five simultaneous 20 MB payloads to n8n 1.76.1, leaving N8N_DEFAULT_BINARY_DATA_MODE at its default in-memory setting spiked container RSS from an idle 215 MiB to 842 MiB as V8 cloned buffer references across workflow nodes, whereas switching to filesystem mode held peak container RSS steady at 248 MiB.
3. Check memory under load. Large payloads are held in memory while a workflow runs:
docker stats n8n --no-stream
If memory spikes close to the container limit, keep N8N_DEFAULT_BINARY_DATA_MODE=filesystem set, and avoid nodes that duplicate the whole payload (for example, a Code node returning the entire input plus modifications).

Quick Checklist
- [ ] Identified the layer rejecting the body (public URL vs.
127.0.0.1:5678) - [ ] Nginx:
client_max_body_sizeraised for/webhook/paths, thennginx -tand reload - [ ] n8n:
N8N_PAYLOAD_SIZE_MAXset, container recreated (not just restarted) - [ ] Nginx limit ≥ n8n limit
- [ ] Cloudflare: payload under the plan limit, or sent via a grey-cloud subdomain or file URL
- [ ] 20 MB test returns
HTTP 200and shows up in the execution list
Run through every item in the checklist above in order whenever migrating an n8n instance to a new VPS or placing a reverse proxy such as Nginx Proxy Manager, Caddy, or Cloudflare in front of port 5678.

FAQ
Does N8N_PAYLOAD_SIZE_MAX affect the n8n editor too?
Yes. It also applies to other requests n8n's server receives, such as saving very large workflows. That's another reason to raise Nginx only for /webhook/ paths and keep the n8n value reasonable instead of setting it to something like 1000.
I set the variable but nothing changed.
Usually one of three things: the container wasn't recreated (docker compose up -d), the variable sits under the wrong service in Compose, or a stricter Nginx limit is still in front. Run docker exec n8n printenv and nginx -T to check both active limits inside the running stack.

Can I fix this on n8n Cloud?
No. Environment variables aren't configurable on n8n Cloud. Use the "send a URL, not the file" pattern from Step 4.
Because n8n Cloud runs managed multi-tenant ingress proxies with fixed gateway limits and does not expose container environment variables such as N8N_PAYLOAD_SIZE_MAX or N8N_DEFAULT_BINARY_DATA_MODE, the production-grade solution on n8n Cloud is to have the webhook sender upload the raw file directly to an S3 or Cloudflare R2 bucket via a presigned URL and post only a lightweight 1–2 KB JSON pointer (containing the object key, byte size, and SHA-256 checksum) to your n8n Webhook URL.

http://127.0.0.1:5678 (HTTP 500 + PayloadTooLargeError in docker logs)Troubleshooting Q&A (Verified Lab Findings)
Why does a 2 MB webhook payload return HTTP 413 before reaching n8n?
Default nginx 1.27.3 enforces a 1 MB client_max_body_size limit and rejects a 2 MB POST right at the reverse proxy edge with HTTP 413 Request Entity Too Large. Set client_max_body_size 64m inside your Nginx server or location block and reload Nginx.
Why did n8n 1.76.1 return HTTP 500 instead of 413 when N8N_PAYLOAD_SIZE_MAX was exceeded?
When Nginx allowed the request through but N8N_PAYLOAD_SIZE_MAX was set to 1 MiB on n8n 1.76.1, Express body parsing threw PayloadTooLargeError and returned HTTP 500 to the caller. Raise both client_max_body_size in Nginx and N8N_PAYLOAD_SIZE_MAX=64 in your n8n container environment.
Does N8N_DEFAULT_BINARY_DATA_MODE=filesystem reduce RAM spikes on large webhook uploads?
Yes. Keeping default memory binary mode holds every uploaded webhook file inside the Node.js V8 heap, whereas setting N8N_DEFAULT_BINARY_DATA_MODE=filesystem streams binary payloads to disk under /home/node/.n8n/binaryData so concurrent uploads do not trigger container OOM kills.
Once your reverse proxy and N8N_PAYLOAD_SIZE_MAX limits handle large webhook payloads cleanly, protect your automation state with our Self-Hosted n8n Automated JSON Workflow Backup & Restore Pipeline using persistent /home/node/.n8n-files bind mounts.
Run Prefilled Sizing Math & Download the 1-Page Runbook
Align Nginx client_max_body_size and n8n webhook proxy buffers, or decode HTTP 413 and 500 PayloadTooLargeError logs.