[BUG] UND_ERR_SOCKET API connection error in official devcontainer on Docker Desktop for Mac (Apple Silicon)
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?
Claude Code fails with UND_ERR_SOCKET error when running inside the official devcontainer on Docker Desktop for Mac.
Claude Code works perfectly on the host Mac - the issue only occurs inside the devcontainer.
Environment
- Host OS: macOS (Apple Silicon / ARM64)
- Docker Desktop: 4.57.0
- Claude Code version: 2.1.17
- Node.js: 20.x (from devcontainer)
- IDE: Tested with both VS Code and JetBrains - same issue in both
Error Message
Unable to connect to API (UND_ERR_SOCKET)
Retrying in 5 seconds… (attempt 6/10)
Debug Log Output
[ERROR] Error in non-streaming fallback: Connection error.
[ERROR] Connection error details: code=UND_ERR_SOCKET, message=other side closed
[ERROR] Error: Error: Connection error.
at XR.makeRequest
(file:///usr/local/share/npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:951:4542)
Debugging Performed
- Firewall disabled - Same error persists
sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -F
- curl works - Direct HTTP requests succeed:
curl -v https://api.anthropic.com # Works fine, TLS handshake completes
- Node.js fetch works - Native fetch succeeds:
node -e "fetch('https://api.anthropic.com').then(r => console.log('OK:', r.status))"
# Output: OK: 404
- Fresh clone - Same issue with clean git clone
- Latest version - Rebuilt without cache to ensure latest Claude Code
- No VPN or proxy - No network interference software
What Should Happen?
Claude Code should work identically in the official devcontainer as it does on the host machine.
Error Messages/Logs
Steps to Reproduce
- Clone the claude-code repository
- Open in VS Code and select "Reopen in Container"
- Wait for container to build and start
- Run claude in the terminal
- Send a message - fails with UND_ERR_SOCKET
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.17
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗