[BUG] Native binary installation ignores HTTP_PROXY for API streaming requests (Bun fetch issue ?)

Status Closed — not planned
Maintainer reply None cached
Activity 9 comments · opened Dec 16, 2025 · 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

Environment

  • Platform: Anthropic API (Claude Max)
  • Claude Code version: 2.0.70 (native binary)
  • Operating System: Linux (Ubuntu-based)
  • Terminal: bash
  • Feedback ID: 14271541-f781-487e-83f6-07c7c4ba17f9
  • Network: Corporate proxy (Fortinet)

Bug Description

The native binary installation of Claude Code fails to connect to Anthropic API when behind a corporate HTTP proxy, while the NPM installation works correctly in the same environment.

Root cause idea: Claude Code uses two different HTTP clients:

  1. axios (with https-proxy-agent) for OAuth/authentication → respects HTTP_PROXY
  2. Bun's native fetch() for API streaming/messages → ignores HTTP_PROXY

Debug logs confirm axios correctly configures the proxy agent, but the streaming requests fail with FailedToOpenSocket / Connection error.

Error Messages

[ERROR] Error streaming, falling back to non-streaming mode: Connection error.
[ERROR] Error: Connection error.
    at makeRequest (/$bunfs/root/claude:747:4547)

Debug Evidence

With CLAUDE_CODE_DEBUG=1 DEBUG=*, logs show:

2025-12-16T09:53:36.081Z https-proxy-agent Creating new HttpsProxyAgent instance: 'http://proxy.company.com:8080/'
...
proxy: http://proxy.company.com:8080/
connectOpts: { ALPNProtocols: [Array], host: 'proxy.company.com', port: 8080 }

OAuth requests succeed (axios), but streaming fails (Bun fetch).

Steps to Reproduce

  1. Set up corporate HTTP proxy environment:

``bash
export HTTP_PROXY=http://proxy.company.com:8080/
export HTTPS_PROXY=http://proxy.company.com:8080/
``

  1. Verify proxy works with curl:

``bash
curl -v --proxy $HTTP_PROXY https://api.anthropic.com/v1/messages
# Returns 405 (expected - GET instead of POST) = connection works
``

  1. Install Claude Code via native binary:

``bash
curl -fsSL https://claude.ai/install.sh | bash
``

  1. Run Claude Code:

``bash
claude
``

  1. Send any message → FailedToOpenSocket error

Expected Behavior

Claude Code should route all HTTP/HTTPS requests through the configured proxy, including streaming API requests.

Actual Behavior

  • OAuth/authentication requests work (axios respects proxy)
  • API streaming requests fail (Bun fetch ignores proxy)
  • Error: Connection error / FailedToOpenSocket

Workarounds Attempted (all failed)

| Workaround | Result |
|------------|--------|
| HTTP_PROXY / HTTPS_PROXY env vars | ❌ Ignored by Bun fetch |
| ALL_PROXY env var | ❌ Ignored |
| NODE_EXTRA_CA_CERTS | ❌ Not a TLS issue |
| NPM installation (npm install -g @anthropic-ai/claude-code) | ✅ Works |

Related Issues

  • #332
  • #1382
  • #217

Additional Context

This blocks enterprise adoption where corporate proxies are mandatory. The NPM version works because Node.js properly handles proxy configuration, while the Bun-based native binary does not.

anonymized_logs.txt

View original on GitHub ↗

9 Comments

github-actions[bot] · 8 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/13475
  2. https://github.com/anthropics/claude-code/issues/7690
  3. https://github.com/anthropics/claude-code/issues/11220

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

Thesam1798 · 8 months ago

This is NOT a duplicate. Here's why:

  • #13475: My issue is about the CLI native binary with corporate proxy.
  • #7690: Related (native binary + proxy) but different error (undefined is not an object vs Connection error/FailedToOpenSocket) and uses AWS Bedrock, not direct Anthropic API.
  • #11220: Specific to statsig/telemetry not respecting proxy. My issue is about the main API streaming requests (not telemetry).

Key difference: My issue identifies the root cause - Claude Code uses axios (respects proxy) for OAuth and Bun's native fetch() (ignores proxy) for API streaming. This explains why authentication works but streaming fails. The NPM installation works because Node.js handles proxy correctly.

This is a distinct bug that needs its own fix: making Bun's fetch() proxy-aware in the native binary.

Safari77 · 8 months ago
jkryanchou · 7 months ago

@Thesam1798 +1 So have Bun's native fix this issue?

Thesam1798 · 7 months ago

@jkryanchou I still have the same issue with versions v2.1.19 & V2.1.20 in Native mode, but it still works when installed via NPM...

github-actions[bot] · 6 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

Allamss · 6 months ago

@claude find the reason and fix it

hangie · 5 months ago

This prevents using Native Installer in Enterprise environments. What is the plan for fixing this? npm is deprecated, but it is the only reliable method.

github-actions[bot] · 5 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.