Skip to content
Solar Account.
Education & Software

How to Fix the "Bad Message 431: Request Header Fields Too Large" Error

The "Bad Message 431: Request Header Fields Too Large" error is an HTTP status code indicating that a server has refused to process a request because its HTTP headers are too long. This typically occurs when browser cookies have accumulated excessively or when...

How to Fix the "Bad Message 431: Request Header Fields Too Large" Error

The "Bad Message 431: Request Header Fields Too Large" error is an HTTP status code indicating that a server has refused to process a request because its HTTP headers are too long. This typically occurs when browser cookies have accumulated excessively or when authentication tokens, such as JWTs, exceed the server's configured header buffer limits.

Contents

Understanding the HTTP 431 Status Code

To resolve the "Bad Message 431" error, one must first understand the architecture of an HTTP request. Every time your browser communicates with a server, it sends a "request." This request consists of three main parts: the request line (e.g., GET /index.html HTTP/1.1), the HTTP headers, and an optional message body.

HTTP headers function as metadata. They provide the server with essential information about the client, such as the type of browser being used (User-Agent), the types of data the client can accept (Accept), and, most importantly, security credentials and cookies. In 2026, as web applications become more complex and decentralized, the volume of data stored in these headers—particularly for tracking, personalization, and cross-site authentication—has grown significantly.

The 431 error specifically targets the "Header Fields." Servers like Nginx, Apache, and Node.js have predefined limits on how large these headers can be. These limits are a security measure designed to prevent Denial of Service (DoS) attacks, such as "Slowloris" or buffer overflow exploits, where an attacker attempts to crash a server by sending massive amounts of header data. When the total size of all headers in a single request exceeds the server’s threshold (often 8KB or 16KB), the server terminates the connection and returns the "Bad Message 431" response.

Common Causes of Header Bloat in 2026

Identifying the root cause of a 431 error is the first step toward a permanent fix. While the error manifests on the client side, the "reason" can stem from either the user's browser state or the server's restrictive configuration.

Excessive Cookie Accumulation

The most frequent culprit is "cookie stuffing" or simply a long history of accumulated cookies. Many modern websites use multiple third-party services for analytics, advertising, and user behavior tracking. Each of these services may drop one or more cookies. Over months of browsing, these cookies aggregate. Since the browser sends every relevant cookie back to the server with every request, the header size can quickly balloon beyond the allowed limit.

Large Authentication Tokens

With the continued dominance of Single Sign-On (SSO) and Microservices in 2026, JSON Web Tokens (JWTs) have become a standard for identity management. These tokens are often stored in the "Authorization" header. If a user belongs to many groups or has extensive permission claims, the JWT itself can become several kilobytes in size. If the application also uses traditional cookies alongside these heavy tokens, the combined size often triggers the 431 status.

Long Referral URLs

The Referer (sic) header contains the URL of the previous webpage. If you are navigating from a URL that contains massive amounts of UTM parameters, tracking IDs, or search queries, that URL string is included in the headers. While a single long URL rarely triggers a 431 error on its own, it can be the "final straw" when combined with large cookies.

Server-Side Misconfiguration

Sometimes, the issue isn't that the client is sending too much data, but that the server is too restrictive. Default configurations for many web servers were established years ago when headers were much smaller. If a company deploys a new feature that adds just a few hundred bytes to a cookie, it might push users over a legacy 4KB limit set on a load balancer or an ingress controller.

Troubleshooting for Regular Users

If you are a visitor to a website and encounter the "Bad Message 431" error, you generally do not have access to the server settings. Your solutions involve cleaning up the data your browser is sending.

1. Clear Cookies for the Specific Site

You do not need to clear your entire browsing history. Most modern browsers allow you to delete cookies for a specific domain.

  • In Chrome/Edge: Click the padlock icon next to the URL, select "Cookies and site data," and click "Manage on-device site data" to remove the stored information for that site.
  • Why this works: This flushes the accumulated "bloat" that is being sent to the server, resetting your request header size to a minimal state.

2. Test in Incognito or Private Mode

Open the website in an Incognito window. Incognito mode starts with a clean slate—no previous cookies or session data are sent. If the site works in Incognito, it confirms that your main browser profile's cookies are the source of the 431 error.

3. Disable Browser Extensions

Some browser extensions, especially those related to privacy, "coupon hunting," or developer tools, may inject custom headers into your requests for tracking or functionality. If clearing cookies doesn't work, try disabling extensions one by one to see if the "Bad Message" disappears.

Advanced Solutions for Web Developers and System Administrators

For developers, a 431 error is a signal that your application's data overhead is approaching a dangerous limit or that your infrastructure is too rigid for modern web demands.

Increasing Header Buffer Limits

The most direct technical fix is to increase the allowed header size in your server configuration. However, this should be done judiciously to maintain security.

  • Node.js: By default, Node.js has a relatively small header limit (8KB-16KB depending on the version). You can increase this by using the --max-http-header-size flag when starting your application. For example: node --max-http-header-size=32768 server.js (this sets the limit to 32KB).
  • Nginx: You need to adjust the large_client_header_buffers directive in your nginx.conf. A common setting for handling large tokens is:
    large_client_header_buffers 4 16k;
    
    This allows up to four buffers of 16KB each.
  • Apache: Use the LimitRequestFieldSize directive. Setting it to 16384 allows for 16KB headers. This directive can be placed in the main server configuration or within a virtual host block.

Auditing Cookie Usage

If you find yourself constantly increasing server limits, the problem is likely your application's architecture. Use the browser's developer tools (Network tab) to inspect the size of your cookies. If Set-Cookie headers are sending massive amounts of data that could instead be stored in a server-side database (using a simple Session ID), migrate that data to the server.

Token Optimization

For JWTs, ensure you are not over-stuffing the payload. Avoid putting long strings, descriptions, or redundant metadata into the token. Use short claim names (e.g., sub instead of subject) and consider using "Reference Tokens" if your identity provider supports them. Reference tokens are small identifiers that the server uses to look up the full claims list in a back-end cache, keeping the HTTP header extremely light.

Comparison of Default Server Header Limits

The following table outlines the typical default limits for various server technologies as of 2026. Knowing these defaults helps in determining if your application is pushing against standard boundaries.

Server Technology Default Header Limit Configuration Parameter
Node.js (v20+) 16 KB --max-http-header-size
Nginx 8 KB (Total) large_client_header_buffers
Apache HTTP 8 KB (Per Field) LimitRequestFieldSize
IIS (Windows) 16 KB MaxFieldLength & MaxRequestBytes
Tomcat 8 KB maxHttpHeaderSize
Spring Boot 8 KB server.max-http-header-size

Best Practices for Preventing Header Bloat

Preventing the "Bad Message 431" error is often more efficient than fixing it after users complain. Implementing a "lightweight header" policy is essential for modern web performance.

  1. Use Domain-Specific Cookies: Avoid setting cookies on the root domain (e.g., .example.com) if they are only needed for a specific subdomain (e.g., app.example.com). This prevents unnecessary data from being sent to your image CDN or API subdomains.
  2. Set Expiration Dates: Many 431 errors occur because old, unused tracking cookies never expire. Always set a reasonable Max-Age or Expires attribute for every cookie.
  3. Implement Server-Side Session Management: Instead of storing user preferences (like theme, language, or complex cart data) in cookies, store them in a fast NoSQL database like Redis and use a single, small Session ID cookie to retrieve them.
  4. Monitor Ingress Controllers: If you are using Kubernetes, ensure your Ingress (like NGINX Ingress or Traefik) has its annotations configured to match your application server's limits. A mismatch here is a common cause of 431 errors in containerized environments.

FAQ: Troubleshooting "Bad Message 431"

Does the 431 error mean the website is down?

No, the website is generally functioning correctly for other users. The 431 error is a "per-request" rejection, meaning the server is specifically rejecting your request because the data your browser is sending is too large. It is a communication mismatch rather than a server failure.

Can a VPN cause a 431 error?

In some cases, yes. Some VPNs or corporate proxies inject additional headers (like X-Forwarded-For or custom security headers) into your request. If your browser's headers are already near the limit, these additional headers added by the VPN can push the request over the threshold, triggering the "Bad Message 431" reason.

Is the 431 error a security risk?

Generally, no. For the user, it is an inconvenience. For the server administrator, the 431 status is actually a security feature. It protects the server from resource exhaustion. However, if a developer sees a sudden spike in 431 errors across their user base, it could indicate a "cookie bomb" attack or a bug in a recent deployment that is creating infinite loops of cookie creation.

Why does this error happen more on Chrome than other browsers?

Chrome and other Chromium-based browsers (like Edge and Brave) are often more aggressive with how they handle and store cookies for third-party scripts. Additionally, different browsers have different internal limits on how much data they will even attempt to send. If Chrome sends the full 16KB and the server only accepts 8KB, you get a 431. If Firefox caps the request at 7KB, the error might not appear, though the site might malfunction due to missing data.

How do I fix the 431 error on a mobile device?

On mobile versions of Chrome or Safari, you must go into the browser settings, navigate to "Privacy and Security," and then "Site Settings" or "Clear Browsing Data." Select "Cookies and Site Data" for the specific website. If the error persists, check if you have any "Content Blockers" or VPN apps active on your phone that might be modifying headers.

Establishing a Proactive Header Monitoring Strategy

To ensure that your users never encounter a "Bad Message 431" reason in 2026, you should integrate header size monitoring into your DevOps pipeline. Modern Application Performance Monitoring (APM) tools can be configured to alert you when the average request header size approaches 70% of your server's maximum limit.

For developers, this means treating HTTP headers as a finite resource. Just as you optimize image sizes and JavaScript bundles for performance, you must optimize the metadata sent in every request. By keeping cookies lean, optimizing JWT payloads, and aligning server-side buffer settings with the actual needs of your application, you can eliminate the 431 error and provide a smoother, more reliable user experience.

Written by

Victoria Hayes

Cybersecurity & Compliance Analyst