Shrink the response headers Chrome refuses on your website
ERR_
What makes response headers grow
Too many or too large cookies
Every cookie the server sets is a separate Set-Cookie header. Storing data in cookie values, setting a cookie per feature or setting the same cookie several times in one response all add up.
One header repeated many times
Code that adds a header inside a loop, or several layers that each add the same header, can repeat it until the section balloons past anything a normal page needs.
Debug data sent as headers
Headers that carry debugging output, such as timings or log lines, can outgrow everything else in the response when they're left switched on in production.
A policy or link header that kept growing
A Content-Security-Policy that lists every domain the site has ever used, or a long run of Link headers, adds bulk to every response the site sends.
Chromium's http_
Measure the headers your server sends
# Count the bytes in the response headers over HTTP/1.1
curl -sS --http1.1 -o /dev/null -D - https://yoursite.com/ | wc -c
# Count the Set-Cookie headers in the response
curl -sS --http1.1 -o /dev/null -D - https://yoursite.com/ | grep -ci '^set-cookie:'
# List the longest header lines with their names
curl -sS --http1.1 -o /dev/null -D - https://yoursite.com/ | awk '{ print length($0), $1 }' | sort -rn | head
Read the numbers
Chrome's HTTP/1.1 limit is 256K, or 262,144 bytes, for the whole header section, so a byte count near or over that number explains the error. curl has a limit of its own, 300 KB of response headers in all, set in its source, so if the commands stop with Too large response headers, the section is past Chrome's limit as well and the counts are partial. The Set-Cookie count shows whether cookies make up the bulk, and the longest lines and the names that repeat most show what to cut first.
How to shrink oversized response headers
- Find the layer adding the headersCompare headers from your app server directly with headers from the public address. A layer that adds headers your app never sent is where to look.
- Trim the cookiesDrop cookies the site no longer uses, keep session data on the server with only an ID in the cookie, and set each cookie once per response.
- Stop repeated and debugging headersFix the loop or the duplicate rule that repeats a header, and turn off debugging headers on the production site.
- Check both protocols afterwardMeasure again, then load the page in Chrome. Over HTTP/2 the same oversized headers show as ERR_
HTTP2_ PROTOCOL_ ERROR, so confirm the fix holds for both.
Frequently asked questions
How big can response headers be in Chrome?
262,144 bytes for the whole header section over HTTP/1.1, written as 256K in Chromium's http_
Is this the same as a 431 error?
No. A 431 means the server refused the headers your browser sent. ERR_
Why do only some visitors get the error?
The big headers may only appear in their responses, for example after they sign in or once a feature sets extra cookies for them. Sign in with a test account of your own, put it in the same state, and add its cookies to the curl commands with -H 'Cookie: ...' to measure a response the way those visitors get it.
Fix related header problems
- Website reliabilityHear about it when your site goes down, not days later from a customer.
- HTTP/2 protocol errorFind the header or stream reset Chrome refuses over HTTP/2, then fix the layer that sends it.
- Cookie securityChoose cookie attributes that fit your sign-in flow and limit unnecessary exposure.