HTTP 431 Request Header Fields Too Large — Oversized Headers
About HTTP 431 Request Header Fields Too Large
HTTP 431 Request Header Fields Too Large means the server refuses the request because the total header size or an individual header exceeds the server's limit. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: Either the total header size or a single header field exceeds server limits. Nginx default header buffer is 4KB-8KB, Apache default is 8KB. Most commonly caused by excessive cookies accumulating over time. Large Authorization tokens (JWT) can push headers over the limit. Can also occur from custom headers, referrer URLs, or user-agent strings. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: Too many or too large cookies accumulated for the domain. Oversized JWT tokens in Authorization header. CDN or proxy adding additional headers that push total over the limit. Large Referer header from a URL with many query parameters. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Clear cookies for the affected domain in your browser. Reduce cookie sizes: use session IDs instead of storing data in cookies. For Nginx: increase large_client_header_buffers (e.g., large_client_header_buffers 4 16k). For Apache: increase LimitRequestFieldSize in httpd.conf. Shorten JWT tokens by reducing claims or using opaque tokens with server-side lookup. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our HTTP Status Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
Why do cookies cause 431 errors?
Cookies are sent as headers with every request. If many cookies accumulate for a domain, the total header size exceeds the limit.
Overview
HTTP 431 Request Header Fields Too Large means the server refuses the request because the total header size or an individual header exceeds the server's limit.
Key Details
- Either the total header size or a single header field exceeds server limits
- Nginx default header buffer is 4KB-8KB, Apache default is 8KB
- Most commonly caused by excessive cookies accumulating over time
- Large Authorization tokens (JWT) can push headers over the limit
- Can also occur from custom headers, referrer URLs, or user-agent strings
Common Causes
- Too many or too large cookies accumulated for the domain
- Oversized JWT tokens in Authorization header
- CDN or proxy adding additional headers that push total over the limit
- Large Referer header from a URL with many query parameters
Steps
- 1Clear cookies for the affected domain in your browser
- 2Reduce cookie sizes: use session IDs instead of storing data in cookies
- 3For Nginx: increase large_client_header_buffers (e.g., large_client_header_buffers 4 16k)
- 4For Apache: increase LimitRequestFieldSize in httpd.conf
- 5Shorten JWT tokens by reducing claims or using opaque tokens with server-side lookup