431 🌐 HTTP

HTTP 431 Request Header Fields Too Large

The request headers — almost always cookies — exceed the server’s size limit.

Seen on: Node.js Nginx

Meaning

Cookies are sent with every request. When an app (or many apps on sibling subdomains) set too many or too large cookies, requests eventually exceed the limit. Node.js’ default header limit is 16 KB; Nginx usually answers 400 “Request Header Or Cookie Too Large” instead of 431.

Common causes

  • Too many / too large cookies for the domain (analytics, A/B tools, auth tokens)
  • Large JWTs stored in cookies
  • Cookies set on the parent domain shared by many subdomains
  • localhost cookies accumulated from many different dev projects

⚡ Quick fix

  1. Clear cookies for the site (or for localhost in development)
  2. Store less in cookies — keep a session ID server-side
  3. Scope cookies to the specific host/path
  4. Raise the limit (Node: --max-http-header-size) only if needed

Detailed fix by platform

Node.js

  1. Raise the header limit:
    bash
    NODE_OPTIONS=--max-http-header-size=32768 npm start

Nginx

  1. large_client_header_buffers 4 32k;

Code examples

Measure cookie size in the browser console

javascript
console.log(document.cookie.length, 'bytes of cookies (excluding HttpOnly ones)');

How to diagnose

  1. Cookies — How many cookies and how large?
  2. Scope — Which domain/path sets them?
  3. Server — What is the header limit?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.