[BUG] Frequent UND_ERR_SOCKET connection failures during active sessions
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?
During active Claude Code CLI sessions, the connection to the Anthropic API drops with Unable to connect to API (UND_ERR_SOCKET) errors. This happens mid-task (reading files, running bash commands) — not at session start. Auto-retry kicks in (up to 10 attempts) and usually recovers, but adds significant delays (30-60+ seconds per occurrence). Multiple occurrences per session today (March 23, 2026). Local internet is stable — other tools and services work fine during the failures.
What Should Happen?
API connections should remain stable during active sessions without dropping mid-task.
Error Messages/Logs
Unable to connect to API (UND_ERR_SOCKET)
Retrying in 2 seconds… (attempt 5/10)
Steps to Reproduce
- Start a Claude Code CLI session
- Give it a multi-step task that involves reading files and running bash commands
- Mid-task, the connection drops with
UND_ERR_SOCKET - Auto-retry attempts 1-10, usually recovers after several attempts
- Not reproducible on demand — happens intermittently throughout the session
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Screenshot 2026-03-23 at 2.32.11 PM
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗