Fix Claude Code "Unable to connect" / fetch failed / ECONNRESET

Troubleshoot terminal proxy mismatches, TLS timeouts, and ECONNRESET drops in Claude Code CLI with a clean custom gateway setup.

ECONNRESETClaude CodeUnable to connect to Anthropic services / fetch failed / ECONNRESET

Root Causes

Common Triggers

  • Browser proxy is active but terminal shell lacks proxy env vars
  • Unstable TUN/VPN routing drops long-running streaming SSE connections mid-response
  • Stale base URL or expired OAuth token cached in ~/.claude/settings.json

Long-Term Stability Path

Direct native routing to https://vip.brioi.com keeps long streaming coding sessions stable.

Step-by-Step Fix

  • Step 1 · Audit terminal environment variablesRun env | grep -iE "anthropic|proxy" to clear conflicting proxy or stale base URLs.
  • Step 2 · Route directly via Brioi native endpointPoint ANTHROPIC_BASE_URL to https://vip.brioi.com to eliminate flaky proxy hops during long streaming tool calls.
  • Step 3 · Persist settings in ~/.claude/settings.jsonStore env keys cleanly so every new terminal session connects reliably.

Working Reference Snippet

Claude Code · ECONNRESET
// ~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://vip.brioi.com",
    "ANTHROPIC_API_KEY": "sk-your-brioi-key"
  }
}

FAQ

Do I still need to log in with a personal Claude account?

No—API key mode bypasses OAuth login loops and personal account limits.

More Troubleshooting Guides