[BUG] Support HTTPS proxy (https:// scheme) for HTTPS_PROXY environment variable
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?
Claude Code 2.x does not support https:// scheme in the HTTPS_PROXY environment variable, resulting in ERR_SOCKET_CLOSED error when trying to connect.
What Should Happen?
Claude Code should support HTTPS_PROXY=https://... either by using a library like https-proxy-agent internally, or by documenting the limitation with a clear error message
Error Messages/Logs
Unable to connect to Anthropic services
Failed to connect to api.anthropic.com: ERR_SOCKET_CLOSED
Please check your internet connection and network settings.
Steps to Reproduce
``zsh``
HTTPS_PROXY="https://user:pass@proxy-host:port" claude login
#### Result
Unable to connect to Anthropic services. Failed to connect to api.anthropic.com: ERR_SOCKET_CLOSED
Claude Model
Not sure / Multiple models
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.193
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
## Environment
- Claude Code: 2.1.193
- OS: macOS 26 (arm64)
- Shell: zsh
## Root cause
The proxy server requires a TLS connection (https:// scheme). Node.js built-in HTTP modules do not support TLS-in-TLS tunneling (connecting to the proxy itself via TLS, then sending a CONNECT request inside that TLS channel). curl supports this since 7.52.0, but Node.js core does not.
## Workaround
Using socat as a local TCP bridge that handles TLS to the proxy:
````
socat TCP-LISTEN:3277,fork,reuseaddr "SSL:proxy-host:port,verify=0" &
HTTPS_PROXY="http://user:pass@127.0.0.1:3277" claude login
3 Comments
I can confirm the same error is reproducible on a Linux machine. Downgrading to Claude Code version
2.1.158is another workaround.I may be hitting the same issue, or a closely related regression.
In my environment, Claude Code fails when
HTTPS_PROXYis set to an HTTPS/TLS proxy endpoint, specifically a Cloudflare Gateway proxy endpoint:Observed behavior:
2.1.193and later fail through this proxy.2.1.159works with the same proxy configuration.curlsucceeds through the same proxy endpoint.Socket is closedtimeout of 10000ms exceededThis appears to be specific to an HTTPS-scheme proxy URL (
HTTPS_PROXY=https://...). I have not confirmed whether the same behavior occurs with a plain HTTP proxy URL.I am not sure whether this has the exact same root cause as this issue, but the symptoms look consistent with Claude Code 2.x not handling HTTPS/TLS proxies correctly. The fact that
2.1.159works and2.1.193+fails suggests this may be a regression between those versions.Tested this on Linux (2.1.233 and your version 2.1.193) with a local TLS-terminating CONNECT proxy using a self-signed cert and
HTTPS_PROXY=https://…:claude loginhangs at "Checking connectivity…" and the startup check fails, as you described.https://user:pass@host:port) and a custom proxy CA viaNODE_EXTRA_CA_CERTSboth work, and an untrusted proxy certificate now produces a clear certificate error instead ofERR_SOCKET_CLOSED.The failure was in the startup connectivity check only (the main API transport already supported
https://proxies), and it was fixed in 2.1.222: "Fixed the startup connectivity check hanging and then failing behind an HTTPS proxy; it now uses the same proxy-aware transport as API requests" — see the changelog.Please update to the latest version (
claude update). Closing — reply here if you still hit this on ≥2.1.222 and we'll reopen.🤖 Generated with Claude Code