chunked HTTP Origin: Network OSI layer 6 · Presentation Last updated 18 Nov 2026

Malformed chunked encoding (invalid chunk size / premature end)

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

Exact message you may see Invalid chunk sizecurl: (56) Malformed encoding found in chunked-encodingParse Error: Invalid character in chunk size
Seen on: HTTP Node.js

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?

🔧 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: Network. Errors that are often confused with or caused by this one (click to open):

102 — HTTP 102 Processing (HTTP)102201 — HTTP 201 Created (HTTP)201202 — HTTP 202 Accepted (HTTP)202203 — HTTP 203 Non-Authoritative Information (HTTP)203CL.TE — HTTP request smuggling: Content-Length vs Transfer-Encoding mismatch (HTTP)CL.TEContent-Encoding — Garbled response: content compressed twice (double gzip) (HTTP)Content-Encodingnet::ERR_INCOMPLETE_CHUNKED_ENCODING — Chrome DevTools: net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK) — response cut off midway (Browser)net::ERR_INCOMPLETE_C…premature close — Response truncated: connection closed before the full body arrived (HTTP)premature closechunked

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.