[BUG] Support HTTPS proxy (https:// scheme) for HTTPS_PROXY environment variable

Status Fixed / completed
Reported on v2.1.193
Maintainer reply ✓ Yes — bcherny
Activity 3 comments · opened Jun 27, 2026 · closed Aug 17, 2026
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

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
``

View original on GitHub ↗

3 Comments

mrsndmn · 2 months ago

I can confirm the same error is reproducible on a Linux machine. Downgrading to Claude Code version 2.1.158 is another workaround.

trogiar · 1 month ago

I may be hitting the same issue, or a closely related regression.

In my environment, Claude Code fails when HTTPS_PROXY is set to an HTTPS/TLS proxy endpoint, specifically a Cloudflare Gateway proxy endpoint:

export HTTPS_PROXY="https://<cloudflare-gateway-proxy-endpoint>:<port>"

Observed behavior:

  • Claude Code 2.1.193 and later fail through this proxy.
  • Claude Code 2.1.159 works with the same proxy configuration.
  • curl succeeds through the same proxy endpoint.
  • The failures happen in at least these flows:
  • updater
  • OAuth token exchange during login/authentication
  • The errors I see are:
  • Socket is closed
  • timeout of 10000ms exceeded

This 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.159 works and 2.1.193+ fails suggests this may be a regression between those versions.

bcherny collaborator · 13 days ago

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://…:

  • 2.1.193: reproduced — claude login hangs at "Checking connectivity…" and the startup check fails, as you described.
  • 2.1.233: works — Claude Code performs a TLS handshake to the proxy, issues CONNECT inside that channel (TLS-in-TLS), and completes login and API requests. Credentials in the proxy URL (https://user:pass@host:port) and a custom proxy CA via NODE_EXTRA_CA_CERTS both work, and an untrusted proxy certificate now produces a clear certificate error instead of ERR_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