net::ERR_CONTENT_LENGTH_MISMATCH Browser Origin: On your device Last updated 15 Oct 2026

Chrome DevTools: net::ERR_CONTENT_LENGTH_MISMATCH — body shorter than the Content-Length header

The server promised a number of bytes in Content-Length and sent a different number, so Chrome treats the download as corrupted.

Exact message you may see Content-Length mismatch
Seen on: Chrome Edge PHP Nginx

Meaning

Classic causes are code that changes the body after the header was written (compression, a BOM, a trailing echo), a proxy/CDN truncating the response, a file being modified while served, and full-disk errors. Compare the header with the real byte count using curl.

Common causes

  • Script outputs extra bytes or modifies the body after headers were sent
  • Compression or minify layer changing size without updating the header
  • Proxy/CDN cutting the response (timeout, buffer, disk full)
  • File replaced or truncated during download
  • Wrong Content-Length set manually

⚡ Quick fix

  1. Do not set Content-Length yourself when output is compressed or generated
  2. Compare: curl -sI Content-Length vs curl -s | wc -c
  3. Fix proxy limits/disk space

Detailed fix by platform

Linux

  1. curl -s https://example.com/file | wc -c and curl -sI https://example.com/file | grep -i content-length

PHP

  1. Remove manual header('Content-Length: …') after ob_start('ob_gzhandler'); avoid output before readfile()

Nginx

  1. Check gzip and sub_filter interplay and proxy_buffering, and disk space for proxy_temp_path

How to diagnose

  1. Numbers — Header size vs real bytes?
  2. Path — Direct to origin or through a proxy?
  3. Change — Does content change while being served?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

411 — HTTP 411 Length Required (HTTP)411captive portal — Browser: This network requires you to sign in — captive portal (hotel, airport, café Wi-Fi) blocking HTTPS sites (Browser)captive portalDNS_PROBE_FINISHED_NO_INTERNET — Chrome: No internet — DNS_PROBE_FINISHED_NO_INTERNET (DNS probe finished, no internet) (Browser)DNS_PROBE_FINISHED_NO…DNS_PROBE_FINISHED_NXDOMAIN — Chrome: This site can’t be reached — server IP address could not be found. DNS_PROBE_FINISHED_NXDOMAIN (Browser)DNS_PROBE_FINISHED_NX…ERR_CONTENT_DECODING_FAILED — Chrome: This page isn’t working — sent an invalid response. ERR_CONTENT_DECODING_FAILED (Browser)ERR_CONTENT_DECODING_…ERR_EMPTY_RESPONSE — Chrome: This page isn’t working — example.com didn’t send any data. ERR_EMPTY_RESPONSE (Browser)ERR_EMPTY_RESPONSEERR_HTTP2_PROTOCOL_ERROR — Chrome: This page isn’t working — example.com is unable to handle this request. ERR_HTTP2_PROTOCOL_ERROR (Browser)ERR_HTTP2_PROTOCOL_ER…ERR_TOO_MANY_REDIRECTS — Chrome: This page isn’t working — example.com redirected you too many times. ERR_TOO_MANY_REDIRECTS (Browser)ERR_TOO_MANY_REDIRECTSnet::ERR_…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.