HTTP status code 431 indicates that the server refuses to process the request because the HTTP request headers are too large. This commonly happens when cookies or custom headers exceed server limits.
? Key Concepts
Request headers contain metadata like cookies, authorization tokens, and user-agent info
Servers enforce size limits on headers for security and performance
Large cookies are the most common cause of 431 errors
? Syntax / Theory
When a client sends headers exceeding the configured limit, the server responds with:
HTTP/1.1 431 Request Header Fields Too Large
? Code Example(s)
? View Code Example
// Sending a request with an excessively large cookie header
GET /dashboard HTTP/1.1
Host: example.com
Cookie: sessionId=very_long_value_repeated_many_times_to_exceed_limits
? Live Output / Explanation
Server Response
The server rejects the request and returns 431 because the cookie header exceeds the allowed size.
? Interactive Example / Diagram
This flow explains how the error occurs:
Request Header Size Simulator
Add "headers" to the request and watch the server response change when the size exceeds 100%.
Server Status: 200 OK
The headers are within the acceptable range.
Browser sends request with large headers
Server checks header size
Limit exceeded → 431 response
? Use Cases
Debugging login issues caused by oversized cookies
API gateways enforcing strict header limits
Security hardening against header-based attacks
✅ Tips & Best Practices
Clear browser cookies to quickly resolve the issue
Store less data in cookies
Increase server header size limits only if necessary
? Try It Yourself
Create multiple cookies in a browser and reload a page