Error Codes Wiki

Chunked Transfer Encoding Errors — Streaming Response Failures

Warning5xx server error

Overview

Fix chunked transfer encoding errors including premature stream termination, malformed chunk headers, and proxy buffering issues in HTTP streaming.

Key Details

  • Chunked transfer encoding allows HTTP responses to be sent in pieces without knowing the total content length upfront
  • Each chunk is prefixed with its size in hexadecimal, followed by CRLF, the data, and another CRLF
  • The stream ends with a zero-length chunk (0\r\n\r\n)
  • Proxies may buffer chunked responses, defeating the purpose of streaming
  • Malformed chunk sizes or missing terminators cause parsing errors in clients

Common Causes

  • Server crash or connection reset before sending the zero-length terminating chunk
  • Proxy or CDN buffering the entire chunked response before forwarding
  • Application error during response generation causing an incomplete chunked stream
  • Network interruption severing the connection mid-stream

Steps

  1. 1Ensure your application properly terminates chunked responses with a zero-length chunk on all code paths including error handlers
  2. 2Disable proxy buffering: Nginx 'proxy_buffering off;' or add 'X-Accel-Buffering: no' response header
  3. 3Implement error handling that sends a proper terminating chunk even when the response generation fails
  4. 4Monitor for incomplete chunked responses using HTTP client error logs
  5. 5Consider using Content-Length instead of chunked encoding when the response size is known upfront

Tags

chunkedtransfer-encodingstreamingproxybuffering

More in 5xx Server Error

Frequently Asked Questions

Use chunked encoding when the response size is unknown at the start (e.g., database query streaming, server-sent events, large report generation). For known-size responses, Content-Length is preferred.