A "400 Bad Request – Request Too Long" error means the web server received a request whose size exceeded a configured limit — almost always the header block rather than the body — and rejected it before any application code ran. The response is typically the web server's own, not the site's, which is why the page looks plain and why your first job is confirming which server is talking: Apache, Nginx, IIS, or a CDN in front. Firefox and Chrome surface the same condition with browser-side messages once a single cookie, or the sum of all cookies, grows past what their own limits allow.
What the Server Means by Request Too Long
The 400 status code itself is generic. RFC 9110 defines it as the server refusing a request because of client error, and "Request Too Long" is the message a particular server attaches to one specific cause: a request line or header section bigger than its buffer. The body of a POST or upload is governed by separate settings, so a request that fails this way usually carries only a few kilobytes — it just carries them in the wrong place.
The size limit is not in the HTTP standard. Each server implements its own ceiling, and that ceiling sits alongside other header limits — maximum single header size, maximum header count — any of which can fire independently. Two requests with identical total size can succeed and fail against the same server depending on how that size is distributed.
For a live site, the failure belongs to whoever controls the server configuration, not to the visitor. A reader who sees this error on a news site or store they don't administer should assume a cookie or extension problem on their side first and a misconfiguration on the site's side second; only the owner can raise the limit.
The most common real-world trigger is authentication state. Sessions, SSO tokens, A/B-testing buckets, and consent flags all travel as cookies, and every cookie adds to the same header budget on every request to that domain. An application that keeps adding cookies eventually crosses the line, and then every request to that host fails at once — including the requests that would otherwise let a user clear the problem.
Reading the Exact Error Message Before You Change Anything
Four servers produce four different variants, and the wording tells you where to look. Apache's core module reports "request header too large" or "Request header field is too large" in its error log and returns 400 to the client. Microsoft's IIS returns "HTTP Error 400. The size of the request headers is too long" for its own header limit and "HTTP Error 400. The request URL is invalid" when a URL crosses the URL-length ceiling. Nginx, when a header buffer overflows, typically answers 400 with a generic bad-request page and logs "client sent too long header line" or "request header or cookie too large" — older versions logged "client sent too long header line" specifically. A CDN or reverse proxy in front may emit its own 400 before the origin sees the request at all.
Match the wording to the layer, then check that layer's settings. If the message names IIS, no amount of nginx tuning helps. If a load balancer sits in front, its request-header limit can reject traffic even when the origin would have accepted it, so you eliminate that tier first before touching the application server.
Browser-side messages are a separate class and deserve separate treatment. Firefox reports "Your connection is not private" for certificate faults — different problem — but for header overflow it has historically shown a 400 page with its own explanation, and Chrome shows ERR_RESPONSE_HEADERS_TOO_BIG when the response headers are oversized, which is the mirror problem. Read carefully: if the failing direction is the response, client cookies and client configuration are innocent.
Write down the exact message and the URL that produced it before changing anything. That single record tells you the server tier, whether the size is in the request or response direction, and whether the same URL fails for every browser. A site owner who skips this step usually raises a limit that wasn't the constraint.
Apache: Raising LimitRequestLine and LimitRequestFieldSize Correctly
Apache's relevant directives are LimitRequestLine (default 8190 bytes, covering the method, URI, and protocol line), LimitRequestFieldSize (default 8190 bytes, per header field), LimitRequestFields (default 100 headers), and LimitRequestFieldSize's aggregate behavior — Apache also caps the combined size of all request headers, and that combined ceiling is the one that trips on cookie-heavy sites. On a typical Debian or Ubuntu install the configuration lives in /etc/apache2/apache2.conf; on RHEL-family systems it's /etc/httpd/conf/httpd.conf, with per-site files under conf.d or sites-enabled.
Find the effective value before editing. Run apachectl -S to confirm which config tree is loaded, then apachectl -M | grep core to verify the core module is active, and search the loaded files for the directive: grep -r LimitRequest /etc/apache2/. The file that actually contains the directive wins; adding a second copy in a lower-priority include does nothing.
When you edit, change the specific directive rather than appending a duplicate. Setting LimitRequestLine 16384 and LimitRequestFieldSize 16384 doubles headroom without opening the door to unbounded requests, and keeping the numbers modest matters — an oversized header limit is itself a denial-of-service lever, because a client can send a 16 KB header block cheaply and make the server buffer it.
Then reload, not restart, and verify. apachectl configtest catches syntax errors before you commit, systemctl reload apache2 (or httpd) applies the change without dropping connections, and a test request with a deliberately large cookie confirms the new ceiling. If the error persists after reload, check whether a reverse proxy in front of Apache has its own limit — that tier is the usual culprit when the logs show nothing.
Nginx: large_client_header_buffers and the Request Line
Nginx has no single "request too long" setting. It has large_client_header_buffers, which controls both the maximum size of the request line and the maximum size of a single header field; the default is 4 buffers of 8 KB each, written as large_client_header_buffers 4 8k;. It also has client_header_buffer_size (default 1k) for the buffer most requests fit in, with the large buffers allocated only when the small one overflows. When a single cookie or an authorization header exceeds 8 KB, the request dies with 400 even though total size is fine.
The aggregate header ceiling is the product of buffer count and size, so large_client_header_buffers 4 16k; raises both the per-field and the combined allowance. The setting goes in the http, server, or location block — it is valid in all three — and a location-level value overrides the server-level one. For a site behind a load balancer, set it in the block that actually terminates the client connection, which is often the balancer's upstream block, not the application's vhost.
Watch for the trap of raising limits at the wrong tier. Nginx in front of an application server will happily pass a 12 KB cookie upstream, only for the backend to reject it with its own 400. Test by sending the oversized request directly to the backend, bypassing nginx, before declaring victory. If the backend rejects it, the nginx change was necessary but not sufficient.
Reload with nginx -t first for syntax validation, then nginx -s reload. The old worker processes drain their connections, so an immediate re-test may still hit the old limit; give it a few seconds. Logs at the info level record the specific buffer that overflowed, which is the fastest way to distinguish "single field too big" from "too many fields total."
IIS and Windows: The Two Separate 400 Causes
IIS splits the problem into two configuration paths that produce different-looking errors. Header overflow is governed by maxFieldLength (per-header bytes, default 16384) and maxRequestBytes (total header size, default 16384) inside the requestFiltering section; the settings live in applicationHost.config under system.applicationHost/sites/siteDefaults/requestFiltering/requestLimits or per-site in a web.config. The URL-length ceiling is separate: maxUrl defaults to 4096 bytes and returns "HTTP Error 400. The request URL is invalid" rather than the header message.
The gotcha is that both limits exist at the server and site level, and a web.config setting can be locked by a server-level setting that prevents override. If editing requestLimits in a site's web.config appears to do nothing, check whether the section is locked in applicationHost.config: the overrideModeDefault attribute governs this, and a locked section throws a configuration error on startup rather than silently ignoring your value. Change the server-level setting or unlock the section explicitly.
For the header-size case, raise maxFieldLength and maxRequestBytes together — raising one without the other just moves the failure. Restart the site (or recycle the application pool) because these are startup-read settings, and verify with a request carrying the same cookie that failed. IIS Manager exposes the values under Request Filtering → Edit Feature Settings, which is the safer path if you are uncomfortable editing XML.
The failure mode to know: a URL that fits the header limit but not the URL limit produces a different 400 message, and technicians chasing "headers too long" waste hours when the real constraint is maxUrl. Read the exact IIS message — they are deliberately worded differently for this reason.
Cookies and Sessions: The Usual Root Cause and How to Shrink Them
Cookies dominate real-world occurrences because they ride every request to a domain and accumulate silently. A site with SSO adds a token cookie; a consent platform adds several; an A/B-testing tool adds assignment cookies; analytics adds more. Each is small, but an authenticated enterprise user on a site with several third-party integrations can easily carry 8–12 KB of cookies, and that is the header that overflows.
Diagnose from the browser. In Chrome's DevTools, the Application panel lists every cookie for the domain with its size in bytes; the Network panel shows the full Cookie request header for any request, and its length in characters approximates the bytes. In Firefox, Storage inspector under the developer tools shows the same data. If one cookie alone is 4 KB, the limit isn't the aggregation — that cookie is the problem and the server needs to stop setting it.
The fix order matters. First, have the application stop minting oversized tokens — split a large JWT into a compact reference and retrieve the payload server-side, or move session state out of cookies entirely. Second, trim third-party cookies by removing integrations the site no longer uses; unused consent and analytics cookies are pure overhead. Third, if a middleware keeps growing a single cookie across a session, treat that as a bug, because the growth is unbounded and the limit is only the first symptom.
Users can't fix a site's cookie growth from their side, and telling them to clear cookies is a workaround, not a repair — clearing them loses the session that the cookie was carrying. Site owners should also expect the problem to return after the next integration is added unless the cookie budget is actively managed.
Browser Limits You Cannot Raise and What They Change
Browsers impose their own ceilings before any request leaves the machine, and those ceilings are not configurable through settings. The widely implemented per-domain cookie count limit is 180 in Chrome and Firefox; each browser also caps a single cookie's size at 4096 bytes (name plus value plus attributes), and Chrome's per-cookie limit is the one most teams hit because it truncates silently rather than erroring. A total cookie size limit sits on top of these, and when the aggregate crosses it the browser stops sending the oldest or least-recently-set cookies.
The practical consequence: a site can be configured to accept 32 KB of headers and still fail because the browser won't send that much. Server tuning above the browser ceiling is pointless for ordinary users, which is why the application-level fix — fewer and smaller cookies — is the durable one. Enterprise proxy or SSO scenarios can push a user past the browser ceiling even when they never see the error on personal devices, so a bug report from one employee isn't evidence the site is broken for everyone.
Reaching the per-cookie byte cap is its own failure. When an application tries to set a cookie longer than the browser allows, the browser drops or truncates it and the session behaves erratically — logins that don't stick, preferences that reset — without ever producing a 400. That symptom deserves a separate investigation from the header-limit case, even though both trace back to cookie bloat.
The useful rule: browser limits are a floor on what configuration can achieve, so measure what the browser actually sends before raising a server value the browser will never exercise.
When a Proxy, Load Balancer, or CDN Fires First
Every tier in front of the application can reject an oversized request, and its limit usually sits lower than any backend's default. A load balancer's request-header buffer, a CDN's header-size ceiling, and a WAF's inspection limit each impose their own caps, so a request can pass the CDN, fail the WAF, or fail the CDN before the origin is even contacted. The 400 you see may originate entirely outside the server you tuned.
Find the tier from the response itself. The server header on the failed response identifies the product; the error page's branding usually names the provider. Then check that tier's documented limit and adjust it in the provider's console or configuration. Cases where the front tier is managed by the hosting provider may need a support request rather than a self-service change.
Measure end to end to see what each hop sees. A request that succeeds directly against the origin but fails through the CDN proves the CDN is the constraint, and a request that fails at the origin but succeeds when sent through the CDN's "origin" bypass path proves the opposite. Log the full request header size at each tier during a controlled test and compare.
The edge scenario that bites: options requests and preflight. A CORS preflight carries Access-Control-Request-Headers listing every header the real request will use, and a site that has accumulated many custom headers can trip a proxy limit on the preflight even when the actual request would have passed. Preflight failures look like CORS errors in the console, which is why they are frequently misdiagnosed as a browser policy problem rather than a header-size one.
Dependency Injection Errors: When the Message Means Something Else
A confusing lookalike error appears in application frameworks: "InvalidOperationException: Unable to resolve service for type … while attempting to activate …". That is .NET's dependency injection container failing to construct a service, and it shares no root cause with a 400 header error, but searchers lump them together because both surface as failures on a request. If the failing message contains "activate" or "resolve service," you are chasing a registration problem in the app's startup code, not a header limit.
The distinction worth holding: HTTP-layer errors come from the server product before the application runs, while DI errors come from the application after it accepted the request. A missing AddScoped/AddSingleton registration, a constructor parameter the container can't satisfy, or a service registered in a scope that the consumer doesn't share all produce the "unable to resolve" message. The fix is in Program.cs or Startup.cs — register the service, or fix the lifetime mismatch.
Recognize the boundary by the status code and the page shape. A raw 400 with a plain server error page means the server rejected the request; a 500 with a stack trace from the framework means the request was accepted and the application failed. Those are different investigations, and starting with the header limits on the wrong one wastes both time and the next person's.
Same principle applies to language-specific lookalikes: a "request too long" from a reverse proxy and a "request too large" from an application body-size limit are different constraints, and fixing the body limit never addresses a header rejection.
A Diagnostic Sequence That Isolates the Constraint
Work from the client outward and don't change two things at once. A controlled sequence tells you which tier and which variable matters.
1: Record the exact error text, status code, and URL. The text names the server tier. 2: Open DevTools → Network, reproduce the failure, and measure the Cookie request header's size. Note any single cookie above 2 KB. 3: Repeat in a private window with extensions disabled and cookies cleared. If the request now succeeds, the constraint is client-side cookie size, not server configuration. 4: Send a minimal request to the same URL with curl -v and a single short header. If that succeeds, the headers were the problem, not the route or method. 5: If the request passes directly to the origin but fails through a CDN or load balancer, tune the front tier first. 6: Change one server directive, reload rather than restart, and retest with the original failing request.
If the error survives all six steps, capture the server log line for the failure and match it to the directive that fired. That log line is authoritative; hunches about which limit is guilty are not. And if the site is maintained by someone else, stop at step 3 and hand over the measurements — raising limits you don't control is not a fix.
FAQ
Does clearing my cookies fix a 400 Request Too Long error?
Temporarily, yes, if cookies are the cause — and the page working after a private-window test is the proof. Clearing them deletes the session data they carried, so you'll be logged out and preferences reset. A site whose cookies regrow past the limit will fail again once the integrations set them again.
How many bytes of request headers are too many?
There is no universal number: Apache's defaults are 8190 bytes for a request line and 8190 bytes per header field with 100 fields max, IIS defaults to 16384 bytes total and per field, and nginx defaults to four 8 KB large buffers. The lowest limit in the chain wins, and that is usually the proxy rather than the application server.
Can I fix ERR_RESPONSE_HEADERS_TOO_BIG with the same steps?
No — that Chrome error means the response headers the server sent back are oversized, so cookies on the request are innocent. The fix is server-side response header trimming, not client cookie cleanup. The confusion arises because both show up in the same browser error family.
Why does the error appear only for logged-in users?
Because authentication is what adds the largest headers: session cookies, SSO tokens, and role cookies only exist after login. An anonymous request carries a few small cookies and fits comfortably under every limit; the same browser logged in can carry several kilobytes more, and that difference is what crosses the threshold.
Is a 400 header error a security problem?
It can be, because oversized header limits are themselves an attack surface — a client can send a large header block cheaply and make the server buffer it. Raise limits in modest steps, keep them bounded, and prefer unfixed defaults when the application doesn't need more headroom. An unbounded header limit trades one failure for a denial-of-service risk.
What if the error only happens on mobile data or a work laptop?
Enterprise proxies and mobile carrier gateways sometimes inject headers or strip them, changing the sizes the origin sees. Test on a plain home connection to rule out the network tier. If it fails only behind one network, the constraint is that network's gateway, and the site owner can't change it.
Does this affect API clients and scripts, not just browsers?
Yes. An API client that sends a long bearer token, a large User-Agent, or many custom headers can trigger the same 400 even with no cookies involved. Check the request's total header size against each tier's configured limit, starting with the proxy nearest the client.
Can I find out which limit fired from my hosting provider?
Usually yes — server error logs at the site or account level record the specific module and directive that rejected the request. If you don't have log access, the hosting provider's support can read the log line. Ask for the exact message rather than a general answer; the wording identifies the tier and the constraint.