[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.
9 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This is NOT a duplicate. Here's why:
undefined is not an objectvsConnection error/FailedToOpenSocket) and uses AWS Bedrock, not direct Anthropic API.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.
The axios bug has been known since 2023.
https://github.com/axios/axios/issues/5256#issuecomment-1454751267
@Thesam1798 +1 So have Bun's native fix this issue?
@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...
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
@claude find the reason and fix it
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.
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.