ECONNRESET kills session — needs auto-retry/reconnect

Resolved 💬 3 comments Opened Feb 10, 2026 by wonderstone843 Closed Feb 13, 2026

Problem

When an ECONNRESET error occurs (API connection forcibly closed by server), Claude Code enters a completely unrecoverable state. The session freezes with 0 thinking tokens and no output. Pressing Ctrl+O to re-trigger shows 0 tokens indefinitely — the connection is dead but the CLI doesn't detect or recover from it.

The only fix is to kill the session entirely and start a new conversation, losing all in-flight context.

Expected Behavior

Claude Code should automatically retry the API request with exponential backoff when it encounters ECONNRESET or similar transient network errors. This is standard practice for API clients.

Suggested behavior:

  • Detect ECONNRESET, ETIMEDOUT, ECONNREFUSED, and similar transient TCP errors
  • Retry with exponential backoff (e.g., 1s → 2s → 4s → 8s, max 3-5 attempts)
  • Display a message like "Connection lost, retrying (attempt 2/5)..."
  • If all retries fail, surface a clear error and let the user manually retry instead of silently hanging forever

Current Behavior

  • Connection drops → session freezes
  • Shows 0 thinking tokens
  • Ctrl+O re-triggers but hangs at 0 tokens again (same dead connection)
  • Ctrl+C is the only escape, and the session context is lost
  • User must restart Claude Code and manually re-establish context

Impact

  • Complete loss of conversation context on every network hiccup
  • Particularly disruptive during long multi-step tasks
  • No way to configure retry behavior (no env var, no setting)
  • Users with unstable connections or during API load spikes are hit repeatedly

Environment

  • macOS (Darwin 25.2.0)
  • Claude Code CLI (latest)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗