HTTP header size limits: nginx 400 and Node 431 errors, measured

There is no limit in the HTTP standard; each server sets its own. Here is where nginx and Node.js start refusing requests, and how to raise the limits.

1. Measured limits

ServerAcceptedRefusedError
nginx, defaultone header of 8,180 bytesone header of 8,191 bytes400 Request Header Or Cookie Too Large
nginx, default, several headers3 headers × 7,000 bytes5 headers × 7,000 bytessame 400
nginx, large_client_header_buffers 4 32k32,000 bytes33,000 bytessame 400
Node.js 24, default16,300 bytes16,400 bytes431, empty body

nginx's default (large_client_header_buffers 4 8k) means each header line, name and value included, must fit in 8 KB, and all of them together in four such buffers. Node counts all headers together against http.maxHeaderSize, which is 16,384 bytes.

2. Raising the limit

nginx (http or server block, then reload):

large_client_header_buffers 4 32k;

Node.js, either for one server or for the whole process (both accepted a 40,000-byte header in our test):

http.createServer({ maxHeaderSize: 65536 }, handler);
node --max-http-header-size=65536 server.js

Behind a proxy or CDN, every hop has its own limit, so raise it on each one or the smallest one still wins.

3. Before raising it: why are the headers so big?

To see the request headers your browser sends, open DevTools → Network → the request → Headers. To try an oversized header on purpose, send one with curl: curl -H "X-Big: $(head -c 9000 /dev/zero | tr '\0' a)" -i https://your-site/.

Frequently asked questions

What is the maximum HTTP header size?

The HTTP standard sets none; servers do. In our tests nginx refused a single header line of about 8 KB by default, and Node.js refused more than 16 KB of headers in total.

How do I fix '400 Request Header Or Cookie Too Large' in nginx?

Users can clear the site's cookies. Server-side, raise large_client_header_buffers (e.g. 4 32k), and find out which cookie or header is so big.

What does HTTP 431 mean?

Request Header Fields Too Large. Node.js returns it when all request headers together exceed maxHeaderSize (16 KB by default).

Do browsers limit header size?

Servers almost always refuse first. We only measured the server side.

Written with AI assistance. Limits were measured on 2026-10-01 by sending growing headers to nginx:alpine 1.31.6 (default and 4 32k buffers) and a Node 24.21 http server (default, maxHeaderSize option and --max-http-header-size flag). PlainHeaders is our extension; the other methods are free.