[BUG] Interactive mode ignores ANTHROPIC_BASE_URL, connects directly to api.anthropic.com

Resolved 💬 2 comments Opened Mar 21, 2026 by markarranz Closed Mar 23, 2026

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

  1. Set ANTHROPIC_BASE_URL to a local proxy endpoint:

``bash
export ANTHROPIC_BASE_URL=http://localhost:8081/anthropic
export ANTHROPIC_API_KEY=sk-ant-...
``

  1. Block direct egress to api.anthropic.com (e.g., via iptables or firewall)
  1. Run claude -p "hi". This works; the request goes through the proxy.
  1. 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.

View original on GitHub ↗

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