API Error: Connection lost mid-response — Causes and Fixes for the Error v2.1.227 Renamed
Claude Code stops partway through a response with "API Error: Connection lost mid-response. The response above may be incomplete." and searching that exact string turns up almost nothing, because the string itself is new. The official error reference states it plainly: before v2.1.227, Connection lost mid-response appeared as Connection closed mid-response, and in the same batch Response stalled mid-stream became The response stopped arriving, while Connection closed while thinking, before producing a response became Connection lost before a response was produced. The event is not new; only the word on screen changed, which is why material written under the old name still applies unchanged and why an issue search has to use both strings. Starting from that rename, this article works only from the official documentation and public issues. It covers the official definitions of the four "cut off mid-response" messages (Server error, Connection lost, Your computer went to sleep, and The response stopped arriving), why the output already on screen is kept deliberately - re-sending the request could execute the same tool call twice - and why the recovery step is to reply continue rather than to start over. It then explains why nothing is retried automatically, using the official Automatic retries branch: a break before anything has completed is re-sent with exponential backoff up to ten times, a break after thinking but before any output is re-sent at most twice and then ends the turn with Connection lost before a response was produced, and a break after a block has completed is not re-sent at all. From there it maps the three layers where a stream can break - your machine and line, the path through proxies and gateways, and the server side with connection reuse - adds the easily missed fourth case of mTLS certificate rotation and its reload behaviour from v2.1.232, and gives a nine-step isolation checklist. It lists the four stream watchdog timers with their defaults (first byte 180s, event level 300s, byte level 180s, body idle five minutes) alongside CLAUDE_CODE_MAX_RETRIES, CLAUDE_CODE_RETRY_WATCHDOG, API_TIMEOUT_MS and the two stream timeout variables, while making clear that raising the retry count does not reduce this particular message. A comparison table separates eight confusable messages, and two public reports, #86473 and #85979, show raw HTTPS and curl completing while only the CLI dies with ECONNRESET. It closes by separating what is officially confirmed from what is only reported, including that builds before v2.1.222 could show this notice even when the response was in fact complete.