[BUG] UND_ERR_SOCKET API connection error in official devcontainer on Docker Desktop for Mac (Apple Silicon)

Resolved 💬 2 comments Opened Jan 23, 2026 by combi-35 Closed Feb 28, 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?

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

  1. Firewall disabled - Same error persists

sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -F

  1. curl works - Direct HTTP requests succeed:

curl -v https://api.anthropic.com # Works fine, TLS handshake completes

  1. Node.js fetch works - Native fetch succeeds:

node -e "fetch('https://api.anthropic.com').then(r => console.log('OK:', r.status))"
# Output: OK: 404

  1. Fresh clone - Same issue with clean git clone
  2. Latest version - Rebuilt without cache to ensure latest Claude Code
  3. 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

  1. Clone the claude-code repository
  2. Open in VS Code and select "Reopen in Container"
  3. Wait for container to build and start
  4. Run claude in the terminal
  5. 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_

View original on GitHub ↗

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