claude-code - 💡(How to fix) Fix [BUG] Persistent "Unable to connect to API (ConnectionRefused)" on macOS — Claude Code and Claude Cowork both fail while Claude.ai web works [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#56242Fetched 2026-05-06 06:33:22
View on GitHub
Comments
2
Participants
2
Timeline
9
Reactions
0
Author
Timeline (top)
labeled ×5commented ×2closed ×1unlabeled ×1

Error Message

Error Messages/Logs

Root Cause

Impact

  • Time-sensitive professional work is blocked.
  • Falling back to the web interface is not always feasible because Claude Code's file/folder access is essential to the workflow.
  • The recurring "ConnectionRefused" pattern across many months suggests an unresolved root cause (possibly the Bun HTTP client per #17541) that warrants reopening rather than per-incident closure.

Code Example

Terminal output:
  Unable to connect to API (ConnectionRefused)
  Retrying in 7 seconds… (attempt 1/10)
  Retrying in 11 seconds… (attempt 2/10)
  
  (loop continues without recovery)

Status page check:
  https://status.claude.com"No incidents reported today" (May 5, 2026)
  However, May 4, 2026 had multiple incidents affecting Claude API,
  Claude Code, and Claude Cowork that may not be fully resolved on the
  client side.

Parallel verification (browser, same machine):
  https://claude.ai → works normally, full response received

Note: I was unable to run `/doctor` or `/feedback` because the CLI
cannot start a session.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

On macOS (Mac mini M4), Claude Code repeatedly fails with: Unable to connect to API (ConnectionRefused) followed by an indefinite retry loop (Retrying in N seconds… (attempt X/10)).

Claude Cowork on the same machine also fails to start.

Meanwhile, Claude.ai in the browser works normally on the same machine and same network, confirming that local networking, ISP, DNS, and account credentials are all healthy. This narrows the problem to the Claude Code / Cowork client stack.

The official status page (https://status.claude.com) currently reports "no incidents," but May 4, 2026 (UTC) had multiple incidents affecting Claude API, Claude Code, and Claude Cowork. The current symptom appears to be residual fallout from those incidents, but it is not acknowledged on the status page.

This pattern matches several previous reports that were closed without a sustained fix:

  • #16331 — Claude Code ConnectionRefused (Jan 2026)
  • #17541 — Connection Refused despite successful curl, suggesting Bun HTTP client issue (Jan 2026)
  • #33355 — Closed as not planned (Mar 2026)

Environment Info

  • Platform: darwin (Mac mini M4)
  • Claude Code version: v2.1.128
  • macOS version: 26.4.1(25E253)
  • Terminal:2.15 (470)
  • Account type: <Max / API>

Steps to Reproduce

  1. Launch claude in Terminal
  2. Any prompt — or even claude --model claude-sonnet-4-5 — triggers: Unable to connect to API (ConnectionRefused) with a retry loop
  3. Claude Cowork app on the same machine also fails to authenticate
  4. Browser-based Claude.ai on the same machine works perfectly

Expected Behavior

Claude Code should connect to the Anthropic API and respond normally, given that the network and account are confirmed healthy via Claude.ai web.

Impact

  • Time-sensitive professional work is blocked.
  • Falling back to the web interface is not always feasible because Claude Code's file/folder access is essential to the workflow.
  • The recurring "ConnectionRefused" pattern across many months suggests an unresolved root cause (possibly the Bun HTTP client per #17541) that warrants reopening rather than per-incident closure.

Request

  1. Please re-investigate the recurring ConnectionRefused symptom on macOS.
  2. If this is downstream of the May 4, 2026 incidents, please update the status page accordingly.
  3. If it is a client-side bug (Bun HTTP client / subscription auth flow), please consider reopening #17541 and #16331 for active tracking, since multiple users continue to experience the same symptom long after each individual issue is closed.

What Should Happen?

Claude Code should connect to api.anthropic.com and respond to prompts normally, given that:

  • The network and DNS are healthy (Claude.ai in the browser works on the same machine and network)
  • The account credentials are valid (login on Claude.ai succeeds)
  • Other Anthropic services are reachable (curl https://api.anthropic.com returns expected responses)

The CLI should not enter an indefinite "ConnectionRefused" retry loop while a parallel browser session to the same backend works without issue.

Error Messages/Logs

Terminal output:
  Unable to connect to API (ConnectionRefused)
  Retrying in 7 seconds… (attempt 1/10)
  Retrying in 11 seconds… (attempt 2/10)
  (loop continues without recovery)

Status page check:
  https://status.claude.com → "No incidents reported today" (May 5, 2026)
  However, May 4, 2026 had multiple incidents affecting Claude API,
  Claude Code, and Claude Cowork that may not be fully resolved on the
  client side.

Parallel verification (browser, same machine):
  https://claude.ai → works normally, full response received

Note: I was unable to run `/doctor` or `/feedback` because the CLI
cannot start a session.

Steps to Reproduce

  1. Open Terminal on macOS (Mac mini M4)
  2. Run: claude
  3. Enter any prompt (e.g., "hello")
  4. Observe: "Unable to connect to API (ConnectionRefused). Retrying in N seconds… (attempt X/10)"
  5. The retry loop continues indefinitely; no successful response is ever returned
  6. Confirm in parallel that https://claude.ai works normally in the browser on the same machine and the same network
  7. Confirm Claude Cowork desktop app on the same machine also fails to authenticate

Reproducible across multiple terminal restarts and multiple hours.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

v2.1.128

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The issue is likely related to a client-side bug, possibly with the Bun HTTP client, causing Claude Code to fail to connect to the Anthropic API on macOS, despite the API being accessible through the browser.

Guidance

  • Investigate the Bun HTTP client configuration and subscription auth flow in Claude Code to identify potential issues.
  • Verify that the curl command can successfully connect to the Anthropic API (curl https://api.anthropic.com) to isolate the problem to the Claude Code client.
  • Check the official status page (https://status.claude.com) for any updates on the May 4, 2026 incidents and their potential impact on the client-side functionality.
  • Consider reopening previous issues (#16331, #17541) related to the ConnectionRefused symptom for further investigation and tracking.

Example

No code snippet is provided as the issue is more related to configuration and client-side functionality rather than a specific code error.

Notes

The issue seems to be specific to the macOS platform and the Claude Code client, as the browser-based Claude.ai works normally on the same machine and network. The problem may be related to a residual fallout from the May 4, 2026 incidents, but this is not acknowledged on the status page.

Recommendation

Apply a workaround by using the browser-based Claude.ai until the client-side issue is resolved, as it is currently the most reliable way to access the Anthropic API.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING