[BUG] Interactive mode ignores ANTHROPIC_BASE_URL, connects directly to api.anthropic.com
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] I can reproduce this bug consistently
Bug Description
Interactive mode (claude) makes a direct connection to api.anthropic.com on startup, ignoring the ANTHROPIC_BASE_URL environment variable. Print mode (claude -p) correctly respects ANTHROPIC_BASE_URL.
This prevents running Claude Code interactively in environments where direct internet access is blocked and API traffic must route through a proxy (e.g., Kubernetes pods with iptables egress rules, corporate networks with API gateways).
Steps to Reproduce
- Set
ANTHROPIC_BASE_URLto a local proxy endpoint:
``bash``
export ANTHROPIC_BASE_URL=http://localhost:8081/anthropic
export ANTHROPIC_API_KEY=sk-ant-...
- Block direct egress to
api.anthropic.com(e.g., via iptables or firewall)
- Run
claude -p "hi". This works; the request goes through the proxy.
- Run
claude(interactive). This fails with:
````
Unable to connect to Anthropic services
Failed to connect to api.anthropic.com: ECONNREFUSED
Expected Behavior
Interactive mode should route all traffic (including startup org/auth/telemetry calls) through ANTHROPIC_BASE_URL when set, the same way print mode does.
Environment
- Claude Code v2.1.80
- Linux (Ubuntu 24.04 container in Kubernetes)
ANTHROPIC_BASE_URLset and verified working with-pmode
Context
We run Claude Code inside isolated Kubernetes agent pods where iptables rules block all external egress from the agent user, forcing traffic through a sidecar proxy. The proxy handles credential injection and policy enforcement. Print mode works perfectly through this setup, but interactive mode bypasses ANTHROPIC_BASE_URL for what appears to be an initial org lookup or auth validation call.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗