[BUG] API Error (Connection error.) with TypeError (fetch failed)

Resolved 💬 11 comments Opened Sep 22, 2025 by pm0code Closed Jan 10, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When making calls to the Claude API, the system is failing with a connection error. The underlying error is reported as a TypeError (fetch failed). The client-side SDK attempts to retry the request with an exponential backoff strategy, but the connection continues to fail across multiple attempts.

Steps to Reproduce
Start Claude from scratch or execute a script or application that makes a request to the Claude API.

The issue appears to be intermittent and may be related to network instability or a client-side configuration issue.

Observe the console or log output for API errors.

Expected Behavior
The API request should complete successfully on the first attempt or succeed after one or two retries if a transient network issue occurs.

Actual Behavior
The API call fails repeatedly, triggering the retry mechanism. Each attempt logs an API Error (Connection error.) followed by a TypeError (fetch failed). The issue persists for at least five attempts, with the retry delay increasing each time.

Environment Details
OS: [Please specify your operating system, e.g., macOS Sonoma, Windows 11, Ubuntu 22.04]

Runtime: [Please specify your runtime, e.g., Node.js v20.11.0, Python 3.10]

SDK/Library: [Please specify the library and version, e.g., @anthropic-ai/sdk v0.20.8]

What Should Happen?

claude should operate normally

Error Messages/Logs

Error Logs
text
  ⎿  API Error (Connection error.) · Retrying in 4 seconds… (attempt 4/10)
    ⎿  TypeError (fetch failed)
  ⎿  API Error (Connection error.) · Retrying in 8 seconds… (attempt 5/10)
    ⎿  TypeError (fetch failed)

Steps to Reproduce

just start the clause from the console

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

Current version: 1.0.120

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

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