[BUG] Native binary installation ignores HTTP_PROXY for API streaming requests (Bun fetch issue ?)
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:
- axios (with
https-proxy-agent) for OAuth/authentication → respectsHTTP_PROXY✅ - Bun's native
fetch()for API streaming/messages → ignoresHTTP_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
- Set up corporate HTTP proxy environment:
``bash``
export HTTP_PROXY=http://proxy.company.com:8080/
export HTTPS_PROXY=http://proxy.company.com:8080/
- 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
- Install Claude Code via native binary:
``bash``
curl -fsSL https://claude.ai/install.sh | bash
- Run Claude Code:
``bash``
claude
- Send any message →
FailedToOpenSocketerror
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.
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗