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

**Code:** `net::ERR_CONTENT_LENGTH_MISMATCH` · **Category:** Browser · **Seen on:** Chrome, Edge, PHP, Nginx

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/browser/err-content-length-mismatch)
