# Malformed chunked encoding (invalid chunk size / premature end)

**Code:** `chunked` · **Category:** HTTP · **Seen on:** HTTP, Node.js

The body claims to use chunked transfer encoding, but the chunk sizes or terminator are wrong.

## Meaning

A proxy, app or buggy framework wrote bad chunk framing, or the connection closed before the final `0\r
\r
` chunk. Clients report invalid chunk size or incomplete chunked encoding. Fix the component that generates the body, update the proxy, and avoid mixing manual Content-Length with chunking.

## Common causes

- Application sent invalid chunk framing
- Connection closed before the last chunk
- Proxy buffering or truncating the stream
- Manually set Content-Length plus chunked
- Compression middleware bug

## Quick fix

1. Capture the response with `curl -v --raw`
2. Update the proxy/framework generating the body
3. Don't set Content-Length when streaming chunked

## Detailed fix by platform

### cURL

1. `curl -sv --raw https://example.com/stream | head -c 400`

## How to diagnose

1. **Chunk sizes** — Valid hex?
2. **Final chunk** — Sent?
3. **Layer** — Which component?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/http/chunked-encoding-malformed)
