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
- Inspect request headers for size anomalies
- Check server maxHeaderSize configuration
- Validate header generation in client code
- Review proxy/gateway header limits
- 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.