HTTP 431 Request Header Fields Too Large
The request headers — almost always cookies — exceed the server’s size limit.
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
- Clear cookies for the site (or for localhost in development)
- Store less in cookies — keep a session ID server-side
- Scope cookies to the specific host/path
- Raise the limit (Node:
--max-http-header-size) only if needed
Detailed fix by platform
Node.js
- Raise the header limit:bash
NODE_OPTIONS=--max-http-header-size=32768 npm start
Nginx
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
- Cookies — How many cookies and how large?
- Scope — Which domain/path sets them?
- 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026