Preflight Checklist
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_URL to a local proxy endpoint:
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_URL set and verified working with -p mode
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.
Preflight Checklist
Bug Description
Interactive mode (
claude) makes a direct connection toapi.anthropic.comon startup, ignoring theANTHROPIC_BASE_URLenvironment variable. Print mode (claude -p) correctly respectsANTHROPIC_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: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:Expected Behavior
Interactive mode should route all traffic (including startup org/auth/telemetry calls) through
ANTHROPIC_BASE_URLwhen set, the same way print mode does.Environment
ANTHROPIC_BASE_URLset and verified working with-pmodeContext
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_URLfor what appears to be an initial org lookup or auth validation call.