[BUG] HTTPS_PROXY is not applied to the Anthropic API POST requests when set in ~/.claude/settings.json
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
What's Wrong?
HTTPS_PROXY behaves differently when set using an environment variable and when set using settings.json.
With HTTPS_PROXY defined using export HTTPS_PROXY=..., everything works as expected and the Anthropic API POST requests go through the proxy.
When HTTPS_PROXY is defined in settings.json (and not in the environment variable), some of the traffic goes through the proxy, but the Anthropic API POST requests go directly to the internet and bypass the proxy.
What Should Happen?
HTTPS_PROXY in settings.json should apply to the Anthropic API POST requests, as if it was defined using the environment variable.
Error Messages/Logs
Steps to Reproduce
Prerequisites: install mitmproxy
- Open the macOS Terminal.
- Run:
export NODE_EXTRA_CA_CERTS=/Users/username/.mitmproxy/mitmproxy-ca-cert.pem
_(Replace the path with the location of your mitmproxy certificate.)_
- Run:
export HTTPS_PROXY=http://127.0.0.1:8080/
- In another Terminal window, run:
mitmproxy --set view_filter=https://api.anthropic.com/v1
- Run:
claude
- Observe the api.anthropic.com POST requests appearing in mitmproxy:
<img width="854" height="451" alt="Image" src="https://github.com/user-attachments/assets/07a763a5-a5e0-4c8b-99fb-19cd2c426033" />
- Close
claude. - Run:
unset HTTPS_PROXY
- Set ~/.claude/settings.json as follows:
{
"env": { "HTTPS_PROXY": "http://127.0.0.1:8080" }
}
- Clear the mitmproxy flows window.
- Run
claudeagain. - Observe that the api.anthropic.com POST requests no longer appear in mitmproxy:
<img width="849" height="450" alt="Image" src="https://github.com/user-attachments/assets/92453e95-f74e-477a-9796-bf9953c9441d" />
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.42 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗