Fix a compressed response Chrome can't unpack
ERR_
Why the body doesn't match its label
The body was never compressed
Code or config that sets Content-Encoding by hand, or a proxy that decompresses a response and passes the header along unchanged, leaves plain HTML under a gzip label. Chrome tries to decompress it and fails.
Text sits in front of the compressed data
A warning, notice or stray output written before compression starts ends up ahead of the compressed stream. The body no longer starts the way gzip requires, so decoding fails at the first byte.
The label names the wrong format
A Brotli body labeled gzip, or a gzip body labeled br, fails too. Chrome decodes gzip, deflate, Brotli and Zstandard, and it picks the decoder from the label alone.
An unknown label passes through
A label Chrome doesn't recognize doesn't cause this error. Chrome skips decoding and shows whatever arrived, which looks like garbage if the body was compressed.
RFC 9110 says Content-Encoding lists the codings a recipient has to undo to get the content back. Chromium's filter_
Fetch the raw response and test it
# See which format the server picks when asked the way Chrome asks over HTTPS
curl -sS -H 'Accept-Encoding: gzip, deflate, br, zstd' -o /dev/null -D - https://yoursite.com/ \
| grep -i '^content-encoding:'
# Ask for the formats this curl supports and let it decompress the reply
curl -sS --compressed -o /dev/null -D - https://yoursite.com/
# Ask for gzip only and save the body without decompressing it
curl -sS -H 'Accept-Encoding: gzip' -o page.gz -D - https://yoursite.com/
# Test the saved body and show its first bytes
gzip -t page.gz
head -c 32 page.gz | xxd
Read the results
The first command prints the format the server claims for Chrome, such as
content-encoding: br, or nothing for an uncompressed response. If the second command prints only headers, curl decompressed the body without trouble. An error such asError while processing content unencodingmeans curl hit the same mismatch Chrome did, and curl exits with code 61, which its manual calls an unrecognized transfer encoding. The second command asks only for formats your curl can decode, so if itscontent-encodingline differs from the first command's, it never tested the body Chrome gets.Run the gzip test only when the third command's headers say
content-encoding: gzip.gzip -tprints nothing for a valid body and an error otherwise:not in gzip formatwhen the body was never gzip, orunexpected end of filewhen it was cut short. A gzip stream always opens with the bytes1f 8b, as RFC 1952 fixes. If xxd shows readable text there instead, such as an HTML doctype or a warning message, the body was never compressed or something wrote in front of it.
How to fix a content decoding error
- Find where the label appearsFetch the page from your app server directly, then through each proxy or CDN in front of it. The first layer where the label and the body disagree is the one to fix.
- Stop setting the label by handRemove code or config that adds Content-Encoding on its own, and let the server's compression module or the CDN set it together with the compressed body.
- Keep stray output out of the bodyTurn off on-screen warnings and notices in production and remove anything that prints before the response starts, so nothing lands in front of the compressed data.
- Fix the label when a layer decompressesA proxy or CDN that decompresses a response to change it has to remove Content-Encoding, or compress the result again under the right label. Then run the curl commands again.
Frequently asked questions
Why does the page load with curl but not in Chrome?
Plain curl doesn't ask for compression or decompress anything, so it never notices a mismatch. --compressed asks only for the formats your curl supports, as curl's manual says, and curl -V lists brotli and zstd under Features when it has them. Chrome over HTTPS asks for gzip, deflate, br and zstd, as Chromium's http_-H 'Accept-Encoding: gzip, deflate, br, zstd' to see the format Chrome gets.
Can a CDN cause this error?
Yes, when it changes a response without keeping the label accurate, for example by decompressing the HTML to rewrite it and passing the original Content-Encoding header along. Compare the headers your server sends with the ones the CDN sends for the same URL to find out.
Why is only one file affected?
The label is set response by response, and compression rules often apply by file type or route. If only a script, a stylesheet or one page fails, test that URL; its handler, or a rule for its type, is where the label goes wrong.
Fix other broken responses
- 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.
- Response headers too bigMeasure your response headers, find the cookie or header that grew, and cut it back.