HTTP 431 · 4XX RFC 6585 §5 Cacheable: No Retryable: No (shrink cookies/headers)

HTTP 431 Request Header Fields Too Large: Root Causes & Production Fix Guide

HTTP 431 Request Header Fields Too Large means one or more request headers (almost always `Cookie` or a bloated JWT `Authorization` header) exceeded the server's header size limit—commonly 16KB in Node.js or 8KB in Nginx.

Top Root Causes of HTTP 431

Node.js & Nginx Header Size Limit Fix for 431

# Node.js / Next.js / Vite (raise to 32KB if needed)
NODE_OPTIONS="--max-http-header-size=32768" npm start

# Nginx
large_client_header_buffers 4 32k;

Verify with cURL

curl -i -sS -w '\nRequest size: %{size_request} bytes\n' https://example.com/

Interactive Stack Diagnoser (HTTP 431)

Frequently Asked Questions

Why do I get 431 on localhost in Next.js or Vite?

Multiple local apps on `localhost` share cookies across ports! Clear cookies for `localhost` in DevTools or raise `--max-http-header-size`.

What is Node.js's default maximum HTTP header size?

Node.js defaults to 16KB (16384 bytes) total for all request headers combined to mitigate DoS attacks.

How do I permanently prevent 431 in production?

Keep JWTs under 2KB by storing session state server-side (Redis/DB) and referencing only a compact opaque session ID in the cookie.

Related Status Guides & Header Tools