All articles
Claude CodeClaudeFixes

Claude Code Streaming response ended before any complete data: Causes and Fixes

Streaming response ended before any complete data means a proxy or gateway broke Claude Code's stream. Pass SSE through unbuffered and test with curl -N.

Claude Code streaming response ended before any complete data
Also available in中文Español

Streaming response ended before any complete data was received means the streaming reply from your model provider closed without a single usable event, so Claude Code sent the same request again without streaming to finish the turn. The usual cause is a proxy, gateway or relay between Claude Code and the provider that buffers, rewrites or drops the stream. Configure it to pass the text/event-stream body and headers through unchanged, then test with curl -N. We reproduced the message on Claude Code 2.1.318 on November 5, 2026; details follow, based on the official error reference.

The full message:

Streaming response ended before any complete data was received. Retrying without streaming. If this keeps happening, check any proxy or gateway between Claude Code and your model provider.

What streaming response ended before any complete data means

Claude Code asks for every reply as a stream of server-sent events and reads them one by one. When the stream ends before the first complete event arrives, Claude Code falls back to a normal request and shows this warning. Points from the docs:

  • The warning appears once per session and only in interactive sessions. Before v2.1.239 Claude Code retried silently.
  • Each affected request is sent twice: the empty streaming attempt and the retry without streaming.
  • Your turn usually still finishes, because the retry gets the answer. The cost is extra latency and a duplicate request on every turn.

Our test: an empty stream on Claude Code 2.1.318

We pointed an isolated Claude Code 2.1.318 at a local mock API that answers streaming requests with 200, text/event-stream and an empty body, and answers non-streaming requests normally:

❯ say ok
● Streaming response ended before any complete data was received. Retrying without streaming. If this keeps happening, check any proxy or gateway between Claude Code and your model provider.
● ok

# what our mock API received for that one prompt
POST /v1/messages  stream=true   -> 200 text/event-stream, empty body
POST /v1/messages  stream=false  -> 200 JSON message

A second prompt in the same session produced two requests again, but no second warning, which matches the once-per-session rule. With claude -p nothing was printed and the answer came back; only the debug log showed the fallback:

[ERROR] Stream completed without receiving message_start event - triggering non-streaming fallback
[ERROR] Error streaming, falling back to non-streaming mode: Stream ended without receiving any events

So if you run Claude Code in scripts, check --debug-file output or your gateway logs for pairs of requests, one with "stream": true and one without.

How to fix streaming response ended before any complete data

  1. Find what sits in the middle. Check ANTHROPIC_BASE_URL, HTTPS_PROXY and any corporate proxy, VPN client or relay. If you use a third-party endpoint, such as the setups in our DeepSeek API for Claude Code guide, that endpoint is part of the path too.
  2. Test the stream outside Claude Code. Send one streaming request with curl to the same URL. If you use a Bearer token, replace the x-api-key line with an Authorization header:
  3. Read the result. A healthy endpoint prints events as they arrive, ending in message_stop. An empty body, a single JSON object, an HTML page, or everything arriving at once after a pause means the middle layer is consuming or buffering the stream.
  4. Turn off buffering and transformation. Per the gateway protocol reference, return content-type: text/event-stream on streamed responses, forward the events in order through message_delta and message_stop, and keep the ping events. On nginx, the relevant switch is proxy_buffering off.
  5. On Amazon Bedrock, the stream is a binary event stream with its own rules; see Streaming errors behind a gateway or proxy.
  6. Retest in a new interactive session. The warning should not come back, and your gateway should log one request per turn.
curl -N "$ANTHROPIC_BASE_URL/v1/messages" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"YOUR_MODEL","max_tokens":32,"stream":true,"messages":[{"role":"user","content":"say ok"}]}'

A healthy response looks like this:

event: message_start
data: {"type":"message_start", ...}

event: content_block_delta
data: {"type":"content_block_delta", ...}
...
event: message_stop
data: {"type":"message_stop"}

A minimal nginx location for a reverse proxy in front of a model API:

location /v1/ {
    proxy_pass https://upstream.example.com;
    proxy_http_version 1.1;
    proxy_buffering off;
}
  • API returned an empty or malformed response (HTTP 200) appears when the non-streaming retry also gets something that isn’t a Claude API message, such as an HTML sign-in page. Then the turn ends with an error (docs).
  • Unable to connect to API means Claude Code couldn’t reach the endpoint at all; see our Unable to connect to API fixes.
  • A 529 comes from the provider being busy, unrelated to your proxy; see Claude Code 529 Overloaded.

FAQ

Can I ignore the warning?

Your answers still arrive, but every turn makes two requests and waits for both. Fixing the proxy removes the extra round trip.

Can I turn the warning off?

We found no setting for it in the Claude Code docs as of 2.1.318.

Is my API key wrong?

Unlikely. The provider accepted the request (200); the problem is what happened to the reply on the way back. Authentication problems show different messages, collected in our Claude Code errors hub.

Sources: Claude Code errors reference, LLM gateway protocol, Amazon Bedrock streaming notes, nginx proxy_buffering, Claude Code changelog (2.1.239). We found no GitHub issue quoting this exact message. Checked November 5, 2026 against Claude Code 2.1.318.

Leave a thought

Your email address will not be published.