Claude Code SOCKS Proxy: Why It Fails and What Works
Claude Code doesn't support SOCKS proxies. See the real errors you get with socks5:// URLs, how to set up an HTTP or HTTPS proxy, and how to bridge SOCKS5 to HTTP.
In this article 9 sections
- Does Claude Code support SOCKS proxies?
- Which hosts Claude Code connects to
- How to set up an HTTP or HTTPS proxy
- HTTP, HTTPS or SOCKS5: what to choose
- How to use a SOCKS5 proxy anyway: a local bridge
- Common errors and what they mean
- Proxies for tools and MCP servers
- Proxy or LLM gateway?
- Frequently asked questions
Claude Code does not support SOCKS proxies. If you put a socks5:// address into HTTPS_PROXY, Claude Code doesn’t stop with a clear error. It hangs and retries. If you put it into ALL_PROXY, Claude Code ignores it and connects directly.
To fix it, give Claude Code an HTTP or HTTPS proxy. If all you have is SOCKS5, run a small local bridge that turns it into an HTTP proxy. Below we show both setups and quote the exact errors Claude Code prints when something goes wrong.
We tested everything below with Claude Code 2.1.332 on macOS and Debian 12 in November 2026. Where we rely on Anthropic’s documentation rather than our own tests, we say so.
Does Claude Code support SOCKS proxies?#
No. Anthropic’s network configuration guide says it directly: “Claude Code does not support SOCKS proxies.” Claude Code reads four environment variables and uses the first one that is set:
https_proxyHTTPS_PROXYhttp_proxyHTTP_PROXY
ALL_PROXY is not on this list. Here is what happened when we tried each SOCKS setup:
| Setting | What Claude Code did |
|---|---|
HTTPS_PROXY=socks5://127.0.0.1:1080 (SOCKS server running) | No output, endless retries. Debug log: Proxy connection ended before receiving CONNECT response |
HTTPS_PROXY=socks5://127.0.0.1:1080 (nothing on the port) | Retries with ECONNREFUSED 127.0.0.1:1080 |
ALL_PROXY=socks5://127.0.0.1:1080 | API requests went directly, bypassing the proxy. Only some background requests failed with Protocol "socks5:" not supported. Expected "http:" |
The last row causes the most trouble, because Claude Code doesn’t warn you about it. Everything keeps working, but the requests go out from your own IP address, and you only find out when you look at the proxy logs.
Which hosts Claude Code connects to#
A proxy has to let Claude Code reach these hosts on port 443. This is a short version of the full list in Anthropic’s documentation:
| Host | Used for |
|---|---|
api.anthropic.com | Claude API requests, feature flags, telemetry |
claude.ai, claude.com, platform.claude.com | Sign-in and token refresh |
sso.claude.com | Sign-in for organizations with single sign-on |
downloads.claude.ai | Native installer and updates |
mcp-proxy.anthropic.com | MCP connectors from claude.ai |
registry.npmjs.org | npm installs, plugins, MCP servers started with npx |
http-intake.logs.us5.datadoghq.com | Operational telemetry (optional, off with DISABLE_TELEMETRY) |
In our tests, the bulk of the traffic went to api.anthropic.com:443, plus the Datadog telemetry host. If you sign in with an API key, you don’t need the sign-in hosts.
How to set up an HTTP or HTTPS proxy#
For a single terminal session, export the variable before you start claude:
export HTTPS_PROXY="http://user:password@proxy.example.com:8080"
claude
To make the proxy apply everywhere, including sessions started from VS Code, JetBrains or over SSH, put it into ~/.claude/settings.json:
{
"env": {
"HTTPS_PROXY": "http://user:password@proxy.example.com:8080",
"NO_PROXY": "localhost,127.0.0.1"
}
}
We checked that this works: with only the settings.json entry and no exported variables, all API requests went through the proxy.
A few rules from our tests and the documentation:
- Always write the scheme.
http://orhttps://must be part of the URL. - Percent-encode special characters in the password. For
p@ss#1, writep%40ss%231. Without encoding, Claude Code tookssas the proxy host and failed withgetaddrinfo ENOTFOUND ss. NO_PROXYaccepts commas, spaces or*. For example,NO_PROXY="localhost,192.168.1.1,.example.com".- Check the result in Claude Code. According to the documentation, the
/statuscommand shows the active proxy.
If your proxy inspects TLS traffic with its own certificate, also add the proxy’s root certificate with NODE_EXTRA_CA_CERTS=/path/to/ca.pem.
HTTP, HTTPS or SOCKS5: what to choose#
The scheme in the URL describes how Claude Code talks to the proxy, not to the website. Your requests to api.anthropic.com are always encrypted, whatever you choose.
| Proxy URL | Connection to the proxy | Works in Claude Code |
|---|---|---|
http://host:port | Plain TCP, then a CONNECT tunnel | Yes |
https://host:port | TLS to the proxy, then a CONNECT tunnel inside it | Yes, tested |
socks5://host:port | SOCKS5 protocol | No |
With http://, the proxy password and the target host name travel unencrypted between you and the proxy. With https://, they are encrypted too. Anthropic’s documentation even lists https:// as the recommended option.
We tested https:// with a TLS proxy that has a public certificate. Claude Code connected to the proxy over TLS 1.3, opened the tunnel and reached the Anthropic API. Two things to keep in mind:
- The proxy must really speak TLS on that port. When we pointed
http://at the same TLS port, Claude Code hung withProxy connection ended before receiving CONNECT response. It’s the same message you get with a SOCKS server, so it doesn’t tell you which mistake you made. - If the proxy’s certificate is self-signed or issued by a private CA, add the CA with
NODE_EXTRA_CA_CERTS.
How to use a SOCKS5 proxy anyway: a local bridge#
If you only have a SOCKS5 proxy or an SSH server, run a small program on your computer. It accepts HTTP proxy requests from Claude Code and forwards them through SOCKS5.
gost#
gost is a single binary with no configuration file. We tested this setup with gost 3.3.3:
gost -L http://127.0.0.1:8181 -F socks5://user:password@socks.example.com:1080
Then point Claude Code at the bridge:
export HTTPS_PROXY="http://127.0.0.1:8181"
claude
In the gost log, you will see CONNECT requests to api.anthropic.com:443. That’s how you know the traffic goes through the bridge.
SSH tunnel#
If you have SSH access to a server, ssh -D gives you a SOCKS5 proxy on your computer. Claude Code can’t use it directly, but you can chain it with gost:
ssh -N -D 127.0.0.1:1080 user@your-server
gost -L http://127.0.0.1:8181 -F socks5://127.0.0.1:1080
export HTTPS_PROXY="http://127.0.0.1:8181"
We tested this chain, too. All API requests went out through the SSH server.
Privoxy#
Privoxy can do the same job if you prefer a package from your system’s repository. Add two lines to its configuration file:
listen-address 127.0.0.1:8118
forward-socks5t / 127.0.0.1:1080 .
Then set HTTPS_PROXY=http://127.0.0.1:8118. We didn’t test Privoxy for this article.
Common errors and what they mean#
These are the exact messages we got from Claude Code 2.1.332.
Wrong proxy password (HTTP 407). Claude Code exits right away:
API Error: Couldn't connect through your proxy (ERR_PROXY_TUNNEL) — the proxy refused the tunnel: check its credentials and that it allows this host
Check the login and password. Also check that the proxy allows your IP address and the target host.
Invalid proxy URL. Claude Code refuses to start:
Invalid proxy URL in HTTPS_PROXY: "http://exa mple:abc" cannot be parsed as a URL.
Proxy settings must be a complete URL including the scheme, e.g. "http://proxy.example.com:8080".
Fix or unset HTTPS_PROXY and restart Claude Code.
Address without a scheme. HTTPS_PROXY=proxy.example.com:8080 doesn’t cause an error. Claude Code quietly treats it as http://. The debug log says HTTPS_PROXY had no scheme: used as an http:// proxy. If your proxy expects TLS on that port, you will get a hang instead of an error.
SOCKS URL or wrong scheme. No output, only retries. Debug log: Proxy connection ended before receiving CONNECT response. Fix the scheme or set up a bridge.
Proxy is down. Claude Code doesn’t fail fast. It retries the request up to 10 more times (API error (attempt 1/11) in the debug log), and you see nothing for a long time.
To see what’s going on, start Claude Code with claude --debug. The debug log is saved under ~/.claude/debug/.
Proxies for tools and MCP servers#
HTTPS_PROXY in Claude Code’s settings covers Claude Code’s own connections. The tools the agent runs, such as browsers, scrapers and MCP servers, are separate programs with their own proxy settings. Unlike Claude Code, many of them accept SOCKS5.
For example, Playwright MCP has the --proxy-server option, and it accepts http:// and socks5:// addresses:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest", "--proxy-server", "socks5://proxy.example.com:1080"]
}
}
}
This way, Claude Code talks to Anthropic through one proxy, while the browser opens websites through another one, for example a proxy in the country you are testing.
FineProxy has a proxy for each part of this setup:
- HTTPS proxies have their own SSL certificate on every IP. The whole connection from Claude Code to the proxy is encrypted, which is the
https://setup Anthropic recommends. - Standard HTTP proxies also work with Claude Code. The connection to the proxy isn’t encrypted, but the traffic to Anthropic inside the tunnel is still HTTPS.
- SOCKS5 proxies are for tools that support SOCKS5, such as Playwright MCP. You don’t need a bridge for them.
Proxy or LLM gateway?#
People often mix these up, because both sit between Claude Code and Anthropic. The difference is what they do with your requests.
A proxy forwards encrypted traffic. It doesn’t see your prompts or responses, and Claude Code works with Anthropic as usual. Use it when you need a different IP address or when your network only allows outgoing connections through a proxy.
An LLM gateway is a separate API server that receives Claude Code’s requests and sends them on to Anthropic. You set it with ANTHROPIC_BASE_URL. A gateway can manage keys, log requests, track costs and limit models. Anthropic’s documentation also recommends a gateway when your corporate proxy needs NTLM or Kerberos sign-in, because Claude Code supports only basic authentication in the proxy URL.
If you just need Claude Code to go out through another IP address, a proxy is enough.
Does Claude Code support SOCKS5?
No. Claude Code works only with HTTP and HTTPS proxies set in HTTPS_PROXY or HTTP_PROXY. To use a SOCKS5 proxy, run a local bridge such as gost or Privoxy that accepts HTTP and forwards to SOCKS5, and point HTTPS_PROXY at the bridge.
Why does Claude Code ignore ALL_PROXY?
Claude Code reads https_proxy, HTTPS_PROXY, http_proxy and HTTP_PROXY, in that order. In our test, ALL_PROXY=socks5://… did not route the API traffic through the proxy at all: requests went out directly, and only a few background requests failed with a protocol error.
Should I write http:// or https:// in HTTPS_PROXY?
Use the scheme your proxy actually speaks on that port. https:// means Claude Code opens a TLS connection to the proxy itself; it worked in our test. If you write http:// for a TLS-only port, Claude Code hangs with the message “Proxy connection ended before receiving CONNECT response”.
How do I put a password with special characters into the proxy URL?
Percent-encode it: @ becomes %40, # becomes %23, : becomes %3A. An unencoded # cuts the URL short, so Claude Code tries to connect to the wrong host.
Where should I set the proxy so it always applies?
Put HTTPS_PROXY into the env section of ~/.claude/settings.json. Claude Code applies it in every session, including ones you start from an IDE or over SSH, where your shell profile may not be loaded.
Does Claude Desktop use a SOCKS proxy from the system settings?
No. According to Anthropic's documentation, Claude Desktop passes only http:// and https:// proxies to the agent. If the system returns a SOCKS proxy, Claude Desktop skips it and logs “Skipping SOCKS proxy entry”.