That error means the server rejected your request before reading the body, because the combined request headers — cookies, Authorization tokens, Referer, and custom headers — exceeded a byte limit the server enforces. The number that reaches you is usually 8,192 bytes: ThinkJS sets its maxFieldsSize default to 8 KB, the same ceiling that pops up in countless Koa and Node.js reports. Your fix depends on one question: are you the visitor or the operator? Visitors clear the oversized cookie or token; operators raise the server limit or stop issuing bloated headers. Everything below splits along that line.
What the 400 Header-Too-Long Error Actually Says Before You Change Anything
The error is a pre-body rejection. The server parses the request line and header block first, and if that block crosses its configured ceiling it answers 400 Bad Request without ever looking at your form data or JSON payload. ThinkJS documents its maxFieldsSize option with a default of 8 KB, which is why 8,192 keeps appearing in reports from that framework family.
Byte counts, not character counts, drive the decision. Headers travel as ASCII bytes on the wire, so a cookie holding 6,000 characters of Base64-encoded JSON may arrive far larger once percent-encoding and attribute names are counted. A browser that stores 300 cookies for one domain can add several kilobytes before any application code runs.
Not every server publishes the same number. Node.js defaults --max-http-header-size to 16 KB, Nginx caps a single request line and header buffer at large_client_header_buffers defaults of 4 buffers × 8 KB, and Apache's LimitRequestFieldSize defaults to 8,190 bytes. The 400 you see is the strictest limit in the chain, not necessarily the one you configured last.
The message text itself is the clue worth reading. Nginx produces "Request Header Or Cookie Too Large" with a 400 status, Node's HTTP parser can surface HPE_HEADER_OVERFLOW, and framework layers stamp their own wording on top. Match the message to the software before editing anything.
Is It Your Cookie or the Server Limit? Count the Bytes in Under Two Minutes
Open DevTools, go to the Network tab, and reload the failing page. Click the failed request, open Headers, and select "Raw" to see the literal header block. Copy that text into any byte counter, or paste it into a text editor that reports size — the total is your evidence.
A faster split test: open the same URL in a private window. Private windows start with no site cookies, so a page that loads there and fails in your normal window points at stored cookie volume. If it fails in both, the token or a proxy header is the likely culprit.
Chrome's cookie inspector tells you how much each domain stores. Open DevTools, then Application, then Cookies, and watch the size column per domain. A single sign-on domain holding 12 KB of cookies will push every request to that domain over an 8 KB server limit.
The decision rule is blunt. Under 8 KB total and still failing: your server's limit is lower than you think, or a proxy sits in between. Over 8 KB: the browser is sending too much, and clearing or trimming cookies buys time while you find what grows.
| Where the limit lives | Default value | Who changes it |
|---|---|---|
| ThinkJS maxFieldsSize | 8 KB | Application developer |
| Node.js --max-http-header-size | 16 KB | Server operator |
| Nginx large_client_header_buffers | 4 × 8 KB | Reverse-proxy admin |
| Apache LimitRequestFieldSize | 8,190 bytes | Web server admin |
| Browser per-domain cookie budget | Roughly 4 KB per cookie, domain totals vary | End user or site owner |
Treat the browser row as a design constraint rather than a documented ceiling across every browser; confirm exact per-browser caps on the vendor's documentation page for your version.
Clear the Oversized Cookie: Chrome, Firefox, Edge, and Safari Paths
Numbered steps for Chrome and Edge, which share the same DevTools layout:
1: Open the failing site, press F12, and choose Application in the top tab strip. 2: Expand Cookies in the left sidebar and select the site's domain. 3: Sort by the Size column and note every cookie above 2 KB. 4: Right-click the largest entries and choose Delete, or clear the whole domain if the site can rebuild them. 5: Reload the page with DevTools still open and watch the Network tab for the same 400.
Firefox users follow a different path: open Settings, then Privacy & Security, then Cookies and Site Data, then Manage Data, search the domain, and remove its entries. Safari on macOS uses Safari, then Settings, then Privacy, then Manage Website Data, then Remove. On iOS, Settings, then Safari, then Advanced, then Website Data lets you delete per-site storage.
Failure handling matters here. If deleting cookies logs you out of everything and the error returns the moment you sign back in, the authentication flow itself is writing too much — a JWT stored in a cookie with large claims is a classic cause. Stop deleting and move to the server-side fix.
Clearing cookies is a workaround, never a repair. It resets the byte count to zero, and whatever grows the headers will regrow them on the same schedule. Schedule the real fix inside the same week or your users will repeat this drill.
Server-Side Fixes: Raise the Header Limit in Nginx, Apache, Node.js, and ThinkJS
Nginx Owners adjust two directives inside the http or server block, then run nginx -t and reload. The first, large_client_header_buffers, sets buffer count and size; the second, client_header_buffer_size, handles the initial read. Doubling the buffer size to 16 KB covers most cookie-heavy applications.
Apache administrators raise LimitRequestFieldSize in httpd.conf and restart. The related LimitRequestFields caps how many separate headers arrive, which matters when an application sends dozens of small custom headers instead of one fat one.
Node.js operators pass --max-http-header-size=32768 on the command line or set maxHeaderSize in the http.createServer options. Applications behind a Node gateway often need both the Node flag and the proxy directive raised, because the smaller of the two wins.
ThinkJS developers change maxFieldsSize in the framework configuration file. The framework documents 8 KB as the default, so setting it to 20 * 1024 gives the same headroom the Node default already provides elsewhere. Version differences exist across ThinkJS major releases, so confirm the option name in your installed version's documentation before editing.
Why the Header Grew in the First Place: JWTs, Tracking Cookies, and Proxy Chains
A large Authorization header is the most common single cause in API traffic. Some teams stuff role lists, permissions, and profile data into a signed JWT, and every request carries that payload back to the server. A token that crosses 4 KB inflates every call, and fifty calls a minute multiply the waste.
Third-party scripts add cookie weight the developer never wrote. A page loading analytics, ads, chat widgets, and A/B testing tools can receive cookies from each vendor's domain, and those cookies attach to requests those scripts make. The failing request may belong to a vendor you forgot was installed.
Chained proxies duplicate headers. Each hop that appends X-Forwarded-For or a correlation ID lengthens the block, and a request passing through four internal services can pick up hundreds of bytes of tracing metadata. Distributed tracing headers like traceparent add their own share.
Long-lived sessions accumulate everything. A user who has browsed a site for two years may carry cookies from retired features, old A/B buckets, and abandoned cart flows. The error often appears after a redesign because the new front end requests a URL that now receives the full legacy cookie jar.
Content Security Policy Report-Only Mode Can Inflate Headers Past the Limit
A less obvious trigger sits in security headers. When a site runs Content Security Policy in report-only mode, the browser sends violation reports as POST requests, and on a page with many policy violations those reports can carry large JSON bodies and sizeable headers at volume. The reports themselves are normal; the volume is not.
This matters because the 400 blocks the report, so the operator loses the telemetry that would explain the problem. A site that suddenly stops receiving CSP reports may be rejecting them at the header layer. Check server logs for 400s on the report endpoint during a policy rollout.
The mitigation is server-side: raise the limit on the report-collection endpoint, or batch reports before sending. Browser-side batching depends on the reporting API version, so verify against the browser vendor's current documentation. Do not disable CSP reporting to silence the error; you lose the audit trail.
Reporting endpoints deserve their own limit because they receive traffic no user initiated. When the block fires here, users see nothing and the operator sees silence — the worst failure mode in this whole family.
A Worked Byte Budget: How One Cookie Jar Crosses 8 KB in Three Months
Start with a realistic baseline and watch it climb. A site using an identity provider cookie (roughly 1,800 bytes), an analytics cookie set (about 900 bytes), a session cookie (400 bytes), and a consent record (600 bytes) already sits near 3.7 KB. That leaves under half the 8 KB ceiling before anything custom appears.
Now add a JWT-based session that stores role claims. If the claim payload grows to 2,500 bytes and Base64 encoding expands it by roughly a third, that single cookie lands near 3,300 bytes. The jar is now past 7 KB, and one more feature — a localization cookie, a feature-flag bucket, a chat widget cookie — pushes it over.
Three months of releases can add four cookies without anyone deciding to. Each feature team adds one, each addition looks small in isolation, and nobody owns the total. The 400 arrives on a Tuesday and the last change shipped six weeks earlier.
The arithmetic gives you a monitoring rule. Sum cookie sizes for your busiest domain once a quarter, and investigate when the total passes 6 KB. That leaves 2 KB of headroom for the Authorization header and proxy additions, which is the buffer between a healthy system and a support ticket.
Diagnosis Table: Match Your Symptom to the Likely Culprit and First Fix
Use the symptom line that matches your failing request, then apply the first fix before touching anything else.
| Symptom | Likely cause | First fix | Second fix if needed |
|---|---|---|---|
| Fails only in your normal browser profile | Cookie jar too large | Clear site cookies | Trim cookies the app writes |
| Fails for every user after a release | New cookie or token in the release | Roll back the release | Shrink the token payload |
| Fails only on one API endpoint | Endpoint receives extra headers | Inspect request in DevTools | Raise the server limit for that route |
| Error text says "Request Header Or Cookie Too Large" | Nginx buffer limit | Raise large_client_header_buffers | Check upstream Node limit |
| HPE_HEADER_OVERFLOW in logs | Node maxHeaderSize | Raise the Node flag | Recheck proxy chain headers |
| Only CSP report endpoint returns 400 | Report volume against a small limit | Give the endpoint its own limit | Batch reports |
| Works on mobile data, fails on office Wi-Fi | Corporate proxy adds headers | Capture headers at the proxy | Whitelist the route |
The table shortens triage but cannot replace reading the actual error message. Every row assumes you confirmed which software emitted the 400; if you skipped that, go back to the raw header view first.
Prevention: Header Budgets, Cookie Hygiene, and Log Alerts That Catch It Early
Set a header budget and treat it like a performance budget. A practical ceiling for application-owned cookies is 3 KB total, leaving the rest for identity, analytics, and the Authorization header. Write the number into your engineering guidelines so feature reviews can reject cookies that blow it.
Audit cookies on a schedule. A quarterly review of your top domains catches retired features that keep writing cookies and vendors that expanded their footprint. Delete anything the current release does not read.
Log every 400 with the request path and user agent. A dashboard chart of header-too-long responses by route reveals which endpoint or which client class triggers the error. Spikes after a deploy point straight at the release.
Raise limits deliberately, not reflexively. Each increase costs memory per connection on the server, and an unbounded limit invites denial-of-service abuse through oversized headers. Pick a number that covers your real traffic with margin and document why.
FAQ
Does clearing cookies permanently fix HTTP error 400 header too long?
No. Deleting cookies resets the byte count but does not stop whatever regrows it, so the error returns on the same schedule unless you find the writer. Treat clearing as triage, then audit which cookie or token grew and change the code or configuration that produces it. Users who report the error twice in a month are telling you the root cause is still live.
Can a single cookie trigger this error on its own?
Yes, if one cookie approaches or passes the per-cookie size cap most browsers enforce around 4 KB and the server limit sits at 8 KB. Browser documentation from Chrome and Firefox describes per-cookie limits in that neighborhood, and a cookie just under the cap plus any other cookies can cross the server ceiling. Split large state across cookies or move it server-side.
Why does the error appear only on one device and not others?
Devices accumulate different cookies, extensions, and proxy settings, so the same URL sends different header blocks from each. A phone that never visited the old version of the site carries a smaller cookie jar than a laptop used daily for two years. Compare the raw headers on both devices before assuming a server bug.
How large is too large for an Authorization header carrying a JWT?
Keep token payloads in the low hundreds of bytes to be safe. A JWT under 1 KB leaves room for cookies and proxy headers under an 8 KB ceiling, while a token with embedded permission lists can pass 3 KB after encoding. Move bulky claims to a server-side lookup keyed by a short identifier in the token.
Is it safe to raise the server header limit to 64 KB?
It works, but it costs memory per open connection and widens the surface for abuse, since an attacker can send huge headers cheaply. Raise to the smallest value that covers legitimate traffic, commonly 16 to 32 KB for cookie-heavy applications, and add request-rate protections at the proxy. Never raise the limit as the only fix while the headers keep growing.
Do browser extensions add headers that cause this error?
Some do. Extensions that inject authentication headers, tracking parameters, or debugging metadata can lengthen requests beyond what the site's own code sends. Test in a clean profile with extensions disabled; if the error disappears, disable extensions one at a time to find the contributor before blaming the server.
Does the same limit apply to HTTP/2 and HTTP/3 traffic?
The transport changes but the ceiling does not disappear. HTTP/2 compresses header fields with HPACK, which shrinks repetitive headers on the wire, yet servers still enforce decoded header-size limits and reject oversized blocks. Confirm the relevant limit on your server or CDN's current documentation, because compression changes the byte count without removing the cap.