Qaynaq LABS · TOOLS

HTTP · 4xx Client Error

431 Request Header Fields Too Large

Server refuses to process request due to oversized request headers exceeding server limits.

When you see this status

  • Client sends headers exceeding server's max header size
  • Proxy or load balancer rejects oversized headers
  • Browser sends maliciously large headers
  • Misconfigured client app generates excessive headers

Common causes

  • Request headers > server's maxHeaderSize
  • Malformed or excessively verbose headers
  • Misconfigured reverse proxy limits
  • Security mechanisms blocking oversized inputs

How to debug it

  1. Inspect request headers for size anomalies
  2. Check server maxHeaderSize configuration
  3. Validate header generation in client code
  4. Review proxy/gateway header limits
  5. Test with minimal headers to isolate issue

Return this code in your framework

Express (Node.js)
res.status(431).send('Headers too large');
FastAPI (Python)
from fastapi import Response
return Response(status_code=431, content="Headers too large")
NestJS
@Get() getData(@Res() res: Response) { res.status(431).send('Headers too large'); }
Go (net/http)
w.WriteHeader(http.StatusRequestHeaderFieldsTooLarge)
w.Write([]byte("Headers too large"))

About HTTP 431

HTTP status code 431 Request Header Fields Too Large is part of the 4xx Client Error family. Server refuses to process request due to oversized request headers exceeding server limits. Understanding it is essential for backend engineers, API designers, and anyone debugging integrations between services.

The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance: what triggers them, how to debug them in production, and exactly how to return them from common frameworks. Each code page is hand-curated and verified.

Frequently asked

Can I increase the server's header size limit?

Yes, configure maxHeaderSize in your server (e.g., Node.js: --max-http-header-size=65536).

Is 431 safe to retry with the same headers?

No, retrying won't resolve the issue unless headers are modified. Investigate header generation.

Does 431 apply to all HTTP versions?

Yes, 431 is defined for HTTP/1.1 and HTTP/2. HTTP/3 uses the same code.