HTTP/4xx (Client Error)
431 Request Header Fields Too Large
The server refuses the request because its header fields are too large.
❓ Why does this happen?
Oversized cookies (often many auth/session cookies on localhost) or huge JWTs in the Authorization header.
✅ How to fix it
Clear cookies for the domain, shrink JWT claims, or raise the Node.js limit with --max-http-header-size=32768.
Return or handle 431 in your stack
// app/api/resource/route.ts
export function GET() {
return Response.json(
{ error: "Request Header Fields Too Large", status: 431 },
{
status: 431
}
);
}Live 431 mock endpoint
Point your app, tests, or retry logic at this free public URL to reproduce a real 431 response (CORS enabled, optional ?delay=ms up to 5000).
https://castov.com/api/mock/431Frequently Asked Questions
What does HTTP Status 431 mean?
Why am I getting a 431 status code?
How do I fix a 431 Request Header Fields Too Large error?
How can I test how my app handles a 431 response?
Other 4xx status codes
Browse the full HTTP status codes directory or troubleshoot terminal errors in the Error Fix Encyclopedia.