Skip to main content
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/431

Frequently Asked Questions

What does HTTP Status 431 mean?
The server refuses the request because its header fields are too large.
Why am I getting a 431 status code?
Oversized cookies (often many auth/session cookies on localhost) or huge JWTs in the Authorization header.
How do I fix a 431 Request Header Fields Too Large error?
Clear cookies for the domain, shrink JWT claims, or raise the Node.js limit with --max-http-header-size=32768.
How can I test how my app handles a 431 response?
Send a request to https://castov.com/api/mock/431 — it returns a real 431 Request Header Fields Too Large response with CORS enabled. Add ?delay=2000 to simulate a slow server.

Other 4xx status codes

Browse the full HTTP status codes directory or troubleshoot terminal errors in the Error Fix Encyclopedia.