How to Set Up a Proxy for Claude Code

Clark
Clark
IPWeb Technical Researcher

Claude Code does not automatically inherit a browser extension or browser-only proxy. The CLI reads its own network configuration, while browser authorization can run in a different process or even on a different host. A reliable setup therefore starts with the terminal process itself, then verifies DNS, TLS, and OAuth behavior separately.

Use one stable endpoint for the first test and keep credentials out of reusable commands, screenshots, and support tickets. Once the terminal path is confirmed, you can compare another approved route without mixing proxy setup with account, region, or OAuth problems.

Quick Answer

Set HTTPS_PROXY or HTTP_PROXY before launching Claude Code, optionally add NO_PROXY, then restart Claude Code so the new environment is loaded. Use /status to check the active proxy and claude --debug when you need more detailed network evidence. Claude Code's documented proxy configuration supports HTTP and HTTPS proxies, but not SOCKS proxies.

Key Takeaways
  • Claude Code reads proxy environment variables at startup; restart the session after changing them.
  • HTTPS_PROXY, HTTP_PROXY, and NO_PROXY are the main proxy variables.
  • Lowercase variants also work, but conflicting variables can make the active route unclear.
  • Claude Code does not support SOCKS proxies through its documented proxy configuration.
  • /status can show the active proxy URL; claude --debug provides deeper diagnostics.
  • A proxy can change network egress, but it cannot fix account eligibility, regional policy, organization permissions, or an expired OAuth code.

Map Which Process Needs the Proxy

Claude Code runs in the terminal, while account authorization may open in a browser. A local terminal, WSL session, SSH host, container, browser profile, and corporate gateway can all use different network paths. Confirm the path that the failing process actually uses before changing any settings.

Process What to verify Useful evidence
Claude Code CLI Which proxy variables the process inherits /status, shell environment, exact error
Browser OAuth Whether the browser uses the intended local or managed route Browser host, authorization result
DNS Whether required Anthropic hostnames resolve Resolver result and host context
TLS Whether a proxy or inspection gateway changes certificate trust Handshake or certificate error
Table 1: Verify the route per process instead of assuming one browser or system setting covers the whole Claude Code workflow.

Configure HTTP and HTTPS Proxy Settings

Anthropic's current Claude Code network configuration documents standard proxy environment variables. Set them before starting Claude Code. For the first test, use one known endpoint and avoid mixing multiple proxy variables unless you know which one should take precedence.

macOS, Linux, or WSL

export HTTPS_PROXY=https://proxy.example.com:8080
export HTTP_PROXY=http://proxy.example.com:8080
export NO_PROXY="localhost,127.0.0.1"

claude

Windows PowerShell

$env:HTTPS_PROXY="https://proxy.example.com:8080"
$env:HTTP_PROXY="http://proxy.example.com:8080"
$env:NO_PROXY="localhost,127.0.0.1"

claude

Lowercase variants such as https_proxy and http_proxy also work. Claude Code uses the first configured value in its documented precedence order, so remove stale variables if you are not sure which route is active.

Important: Claude Code does not support SOCKS proxies through this documented configuration. If a proxy provider offers several protocols, use an HTTP or HTTPS endpoint for Claude Code itself.

Scope note: These shell examples apply directly to standalone Claude Code sessions launched from that terminal. Claude Desktop-managed Code or background-agent sessions can use managed settings or Claude settings files instead of inheriting every value from your interactive shell, so verify the configuration source used by the session you are actually testing.

VS Code settings.json showing http.proxy, https.proxy, and Claude Code http_proxy and https_proxy environment variables
Figure 1: A real VS Code settings.json example showing proxy-related fields for Claude Code. Other token or base-URL entries visible in this local setup are not required for the proxy configuration described here.

Bypass specific destinations with NO_PROXY

NO_PROXY can be comma-separated or space-separated. Use it only for destinations that should not pass through the proxy.

export NO_PROXY="localhost,127.0.0.1,.example.com"

Restart and Verify Claude Code

Proxy environment variables exported in a shell are read when Claude Code starts. A Claude Code session that is already running does not automatically pick up later shell changes. After changing HTTPS_PROXY, HTTP_PROXY, NO_PROXY, or related certificate variables, close the current session and launch Claude Code again.

Inside an interactive session, run /status. Anthropic's current documentation says the status view can show the active proxy URL and flag a proxy value that is invalid or ignored. This is more reliable than assuming the CLI inherited the same route as the browser.

Claude Code terminal welcome screen showing the status command for checking the current setup
Figure 2: Claude Code exposes the /status command for checking the current setup before deeper network troubleshooting.
/status

For deeper diagnostics, start a fresh session with debug logging:

claude --debug

Claude Code writes debug output to its debug directory rather than printing every detail into the terminal. Use that output to confirm network and certificate configuration without exposing passwords, OAuth codes, API keys, or session values.

Verify the Setup End to End

A proxy configuration is not fully verified just because the environment variable exists. Confirm three layers in order: Claude Code sees the intended proxy, the network configuration loads without parsing or TLS errors, and a real Claude Code request completes successfully.

Verification Sequence
  1. Check the active route: run /status and confirm the Proxy entry matches the endpoint you intended to use.
  2. Check configuration loading: restart with claude --debug and review the debug output for proxy, certificate, or ignored-setting errors.
  3. Run a real smoke test: send one minimal non-interactive request and confirm that Claude Code returns the expected response.
claude -p "Reply only with OK"

If the command returns OK, the test verifies more than basic TCP reachability: Claude Code started, authentication was usable, the configured network path reached Anthropic, and a model request completed. If /status shows the correct proxy but this request fails, stop treating the problem as “proxy not configured” and move to the specific error layer shown by the CLI.

Use that distinction in support records. A successful /status result proves that Claude Code loaded a proxy setting; a successful claude -p request provides much stronger end-to-end evidence that the route works for an actual Claude Code request.

Diagnose DNS, TLS, and OAuth in Order

Resolve lower network layers before diagnosing authentication. If the terminal cannot resolve an Anthropic hostname, OAuth is not the first problem. If DNS succeeds but TLS fails, check certificate trust and corporate inspection. Only after the connection is healthy should an HTTP response or browser-to-terminal OAuth symptom be interpreted.

Anthropic's network requirements include endpoints such as api.anthropic.com, claude.ai, claude.com, and platform.claude.com for API requests and account authentication. Restricted corporate environments may need these destinations allowed through the proxy or firewall.

curl -I https://api.anthropic.com
curl -I https://claude.ai

A non-200 HTTP response does not automatically mean the network path failed. At this stage, the main goal is to confirm that DNS resolution works and that the TLS connection can reach the destination. Interpret the HTTP status only after those lower network layers are healthy.

Claude Code terminal showing repeated API Error Connection error and TypeError fetch failed retries
Figure 3: Repeated connection and fetch failures are network symptoms; verify the proxy, DNS, and TLS path before treating them as OAuth errors.

If the browser authorization succeeds but Claude Code remains waiting, or the terminal reports OAuth error: Invalid code, 403, or another authentication-specific error, move to the Claude Code login troubleshooting guide. Do not duplicate OAuth troubleshooting inside the proxy workflow.

If the exact message is App unavailable in region, use the separate Claude Code region-error guide. A proxy test should not be treated as a way to change Anthropic's availability policy.

Use a Stable Route Before Rotation

Start with stable egress because a fixed route makes repeated results comparable. Rotation changes the public IP and can also change location, ISP, ASN, DNS behavior, or upstream path before the original failure is understood.

If a proxy is already configured, first confirm that the same Claude Code process is actually using it. IPWeb's proxy validation guide shows how to compare the visible IP, country, ISP, ASN, protocol, and application scope instead of assuming the route is active.

For approved network QA that requires one consistent residential exit across repeated Claude Code tests, IPWeb Static Residential Proxies can provide a stable comparison endpoint. Use the product's HTTP or HTTPS endpoint with Claude Code; its documented proxy configuration does not support SOCKS proxies. The purpose is repeatable route testing, not account access, region eligibility, or OAuth repair.

Handle Corporate TLS and Authenticated Proxies

If an enterprise proxy performs TLS inspection, the problem may be certificate trust rather than proxy reachability. Claude Code can use the operating system certificate store and can also be configured with an additional CA certificate when required by the organization.

export NODE_EXTRA_CA_CERTS=/path/to/corporate-ca.pem

On Windows PowerShell, use the same variable in the current session:

$env:NODE_EXTRA_CA_CERTS="C:\path\to\corporate-ca.pem"
Anthropic Claude Code GitHub issue reporting a self signed certificate error on WSL
Figure 4: A real Claude Code GitHub issue shows a self-signed certificate failure, a common signal that corporate TLS inspection or CA trust needs attention.

If a proxy requires Basic Authentication, Anthropic documents credentials in the proxy URL. Do not hardcode a real password into reusable scripts, documentation, screenshots, or support tickets. Source the complete proxy value from a protected environment or credential store and redact the secret from diagnostics.

export HTTPS_PROXY="http://username:password@proxy.example.com:8080"

Make a Safe Support Record

Record the proxy scheme, host type, shell, Claude Code version, active proxy result from /status, DNS result, TLS result, browser OAuth host, callback result, and timestamp. Redact proxy usernames and passwords, OAuth codes, browser cookies, authorization headers, API keys, and session links.

A useful support record should show which layer failed without exposing the credentials needed to reproduce the route.

Frequently Asked Questions

Does Claude Code support SOCKS5 proxies?

No. Anthropic's current Claude Code network configuration states that SOCKS proxies are not supported. Use an HTTP or HTTPS proxy endpoint for Claude Code itself.

Why is Claude Code not using the proxy I just configured?

Claude Code reads shell proxy environment variables at startup. If the session was already running when you changed HTTPS_PROXY, HTTP_PROXY, or NO_PROXY, restart Claude Code and check /status again.

How can I check which proxy Claude Code is using?

Run /status in an interactive Claude Code session. The status view can show the active proxy URL and indicate when a proxy value is invalid or ignored. Use claude --debug for deeper network and certificate diagnostics.

Can Claude Code use an authenticated HTTP proxy?

Yes. Basic Authentication can be supplied in the proxy URL. Keep the real credential in a protected environment or credential store, and redact it from scripts, screenshots, logs, and support tickets.

Why does Claude Code fail when the browser OAuth page works?

The browser and terminal can use different network paths or run on different hosts. A successful browser approval also does not prove that the OAuth result returned to the waiting Claude Code process. If the route is healthy, continue with Claude Code-specific login troubleshooting.

Should I use a rotating proxy for the first Claude Code test?

No. Use one stable endpoint first so DNS, TLS, response class, and OAuth behavior can be compared under the same network conditions. Introduce another approved route only after the baseline is understood.

Can a proxy fix a Claude Code account or region error?

No. A proxy changes the network route. It cannot create account entitlement, change organization permissions, repair expired OAuth credentials, or make an unsupported region officially supported.

How do I know my Claude Code proxy setup is actually working?

Verify it in layers. First confirm the intended proxy in /status, then check a fresh claude --debug session for proxy or TLS configuration errors, and finally run a real request such as claude -p "Reply only with OK". A successful model response is stronger evidence than a proxy variable or curl test alone.

Final Thoughts

A reliable Claude Code proxy setup starts with one supported HTTP or HTTPS endpoint, a fresh Claude Code process, and a verified active route. Check /status, inspect a fresh claude --debug session when needed, and finish with a minimal claude -p request before calling the setup verified.

Keep the network path separate from account and regional policy. Stable egress can make route testing repeatable, but Claude Code login, organization permissions, and availability errors still need their own diagnostic paths.

About the author
View all articles
Clark
Clark
IPWeb Technical Researcher

A technical writer specializing in IP proxy services and network architecture. All content is derived from over six years of hands-on experience at a leading IP proxy provider, covering areas such as large-scale proxy network orchestration, optimization of SOCKS5/HTTP protocol stacks, and the dynamics of anti-scraping strategies and countermeasures. The goal is to dissect the engineering logic underpinning network security, stability, and efficiency.

Service areas
Proxy IP network architecture anti-scraping countermeasures protocol optimization for web scraping large-scale data collection engineering

You may be interested in

503 Backend Is Unhealthy cover showing backend health checks, CDN or load balancer routing, and origin server status

What Does 503 Backend Is Unhealthy Mean?

You receive an HTTP 503 response, but the page does not just say “Service Unavailable.” Instead, it says “backend is unhealthy,” “no healthy upstream,” or “no server is available to handle this request.” Those messages narrow the problem: a front-end layer received the request but could not select or reach a backend that it considered healthy. The useful question is no longer “What does HTTP 503 mean?” It is which backend-selection or health-check layer produced the message, and why did every eligible upstream fail? Quick Answer “503 backend is unhealthy” usually means a reverse proxy, load balancer, CDN, or gateway...

Marcus

Marcus

Proxy Network Analyst

How to Build an HTTP Proxy Server with Node.js cover showing HTTP forwarding and HTTPS CONNECT tunneling

How to Build an HTTP Proxy Server with Node.js

Your Node.js proxy forwards ordinary HTTP requests, but the moment you try an HTTPS URL the request hangs, closes, or never reaches the same request handler. That is the most common point of confusion in a hand-built HTTP proxy: HTTPS does not use the same forwarding path as plain HTTP. The practical fix is to handle CONNECT separately. A working proxy needs one path for normal HTTP requests and another path that opens a TCP tunnel for HTTPS. The steps below start from the failure, reproduce it on Windows, add CONNECT support, and then show how to tell whether a...

Clark

Clark

IPWeb Technical Researcher

Claude API proxy setup in Python with a proxy server between Python code and the Claude API

How to Use a Proxy with Claude API in Python

A Python application that calls the Claude API normally uses the network route available to the process that runs it. When you need a specific outbound route for development, fixed-egress testing, or an approved network environment, the Anthropic Python SDK can send requests through an explicit proxy instead of relying on the machine's default connection. The current Anthropic Python SDK uses httpx2 for its HTTP layer and lets you customize that layer with DefaultHttpxClient. Anthropic directly documents an HTTP proxy configuration, while HTTPX2 also provides optional SOCKS proxy support. That makes it possible to use either an HTTP proxy or...

Clark

Clark

IPWeb Technical Researcher

Ready to scale your data operations?
Join 10,000+ teams using IPWeb to power their web data collection. Start free today.

Strictly anti-abuse

Fraud, automated operation, and unauthorized use are prohibited.

Enterprise-level services

For legitimate commercial and technical use cases only

Risk control and restrictions

Abnormal behavior may trigger service restrictions or termination.

Compliance data use

Data acquisition and use must comply with relevant regulations.

Privacy protection first

The collection or misuse of sensitive personal information is strictly prohibited.

All services are subject to《the Usage Policy》