Skip to content

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

Description

@markarranz

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • 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:

    export ANTHROPIC_BASE_URL=http://localhost:8081/anthropic
    export ANTHROPIC_API_KEY=sk-ant-...
  2. Block direct egress to api.anthropic.com (e.g., via iptables or firewall)

  3. Run claude -p "hi". This works; the request goes through the proxy.

  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:networkingbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:linuxIssue specifically occurs on Linux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions