Configuring Claude Code and Codex behind a proxy, firewall, or custom CA certificate
How to configure HTTPS_PROXY, NO_PROXY, custom CA certs (NODE_EXTRA_CA_CERTS, CODEX_CA_CERTIFICATE) and mTLS for Claude Code and Codex, plus SOCKS limits.


The short answer
Claude Code reads HTTPS_PROXY / HTTP_PROXY and NO_PROXY at startup (HTTP/HTTPS only — SOCKS proxies are not supported) and trusts custom root certificates via NODE_EXTRA_CA_CERTS or the OS trust store. Codex trusts corporate root certificates via CODEX_CA_CERTIFICATE (falling back to SSL_CERT_FILE). Set the variables before launching the CLI so the process picks them up.
| Need | Claude Code | Codex |
|---|---|---|
| HTTP / HTTPS proxy | HTTPS_PROXY / HTTP_PROXY / NO_PROXY | HTTPS_PROXY / HTTP_PROXY / NO_PROXY |
| SOCKS proxy | Not supported (use HTTP/HTTPS proxy) | Use HTTP/HTTPS proxy for predictable TLS & WebSocket |
| Custom CA bundle (PEM) | NODE_EXTRA_CA_CERTS | CODEX_CA_CERTIFICATE (fallback: SSL_CERT_FILE) |
| Proxy mangles gzip bodies | CLAUDE_CODE_GZIP_REQUEST_BODIES=0 | Check proxy streaming / compression passthrough |
| Client cert (mTLS) | CLAUDE_CODE_CLIENT_CERT + CLAUDE_CODE_CLIENT_KEY | Configure through enterprise gateway / proxy |
Claude Code proxy, CA store, and mTLS
Claude Code checks proxy variables in the order https_proxy, HTTPS_PROXY, http_proxy, HTTP_PROXY once at startup (or reads them from the env block of your user settings.json). Loopback WebSockets (localhost, 127.0.0.0/8, ::1) never go through the proxy.
# HTTP/HTTPS proxy (SOCKS proxies are not supported)
export HTTPS_PROXY="http://proxy.example.com:8080"
export NO_PROXY="localhost,127.0.0.1,.internal.example.com"
# Trust a corporate TLS-inspection root CA
export NODE_EXTRA_CA_CERTS="/etc/ssl/certs/company-ca.pem"
# Disable gzip request compression if a TLS proxy rejects compressed bodies
export CLAUDE_CODE_GZIP_REQUEST_BODIES=0- OS trust store vs. bundled CAs: by default Claude Code trusts both bundled Mozilla CAs and your OS trust store (
CLAUDE_CODE_CERT_STORE=bundled,system). The native installer always reads the OS store; npm installs need Node 22.15 or later. - mTLS rotation without restart: set
CLAUDE_CODE_CLIENT_CERT,CLAUDE_CODE_CLIENT_KEY(and optionalCLAUDE_CODE_CLIENT_KEY_PASSPHRASE). From v2.1.232, Claude Code automatically re-reads rotated cert/key files on TLS handshake or connection-reset errors. - Desktop security scope: in app-managed Claude Desktop sessions, proxy and certificate variables are read only from managed settings and user
settings.json— repo-level settings are ignored so an untrusted repo can't redirect traffic.
Codex behind a corporate TLS proxy
If codex login or streaming responses fail with TLS or certificate errors behind a corporate proxy, point CODEX_CA_CERTIFICATE at your company's PEM CA bundle. Codex uses it across HTTPS requests, login flows, and WebSocket connections, and checks it before SSL_CERT_FILE.
export HTTPS_PROXY="http://proxy.example.com:8080"
export CODEX_CA_CERTIFICATE="/etc/ssl/certs/company-ca.pem"
codex loginWorking smoothly across networks in Mirasim
- Keeps your local CLI network config: Mirasim launches your installed Claude Code and Codex CLIs directly, so existing
HTTPS_PROXY,NO_PROXY,NODE_EXTRA_CA_CERTS, andCODEX_CA_CERTIFICATEsettings keep working. - Switch to reachable endpoints or local models per session: when one upstream is blocked or flaky on your current network, switch that session to a provider your network reaches (DeepSeek, Kimi, GLM, Qwen, or a local Ollama /
mlx-lmmodel) or run on Mirasim credit without rewriting shell profiles.
Chapter 16 · Models, accounts and quota › Bring your own keys → Configuring custom endpoints, local models, and Mirasim credit per session.
Questions
- Does Claude Code support SOCKS5 proxies?
- No. Anthropic's network configuration docs explicitly state that Claude Code does not support SOCKS proxies — expose an HTTP or HTTPS proxy port instead and set
HTTPS_PROXY. - Why does Claude Code ignore proxy changes I exported after starting it?
- Claude Code reads shell environment variables once at startup. Quit and relaunch
claudeafter exportingHTTPS_PROXY, or put the variables in theenvblock of your usersettings.json. - Which variable takes precedence in Codex:
CODEX_CA_CERTIFICATEorSSL_CERT_FILE? CODEX_CA_CERTIFICATEtakes precedence overSSL_CERT_FILEacross HTTPS, login, and WebSocket clients.
Article · Claude Code errors: fixing 529 Overloaded, 429, Prompt is too long, and connection errors → Claude Code connection errors: `Unable to connect to API`, `ERR_PROXY_TUNNEL`, and `Socket is closed`.
Article · Codex “stream disconnected before completion”: what it means and how to fix it → Fixing Codex “stream disconnected before completion” behind proxies and VPNs.
Article · Using an API key with Claude Code and Codex: setup, custom endpoints, and switching back → Routing Claude Code and Codex through an LLM gateway or custom base URL.
Article · Running Claude Code and Codex on Amazon Bedrock, Vertex AI, and Microsoft Foundry → Running Claude Code and Codex through Amazon Bedrock, Google Cloud Vertex AI, or Microsoft Foundry.
Sources
Checked on November 29, 2026 against Anthropic's Enterprise network configuration docs (code.claude.com/docs/en/network-config) and OpenAI's Codex environment variables docs (learn.chatgpt.com/docs/config-file/environment-variables). Check those pages for the latest variables.
Keep reading

Fixing OpenAI and Codex 403 “unsupported_country_region_territory”
Why OpenAI and Codex return 403 unsupported_country_region_territory, how to fix false positives on VPNs or cloud IPs, and compliant alternatives.

Running Claude Code and Codex on Amazon Bedrock, Vertex AI, and Microsoft Foundry
Connect Claude Code and Codex to Amazon Bedrock, Vertex AI, and Microsoft Foundry: env vars, config.toml, auth, model pinning, and limits.

Using Claude Code with Chrome and Codex Browser: live debugging, Playwright, and previews
How to connect Claude Code to Chrome (extension, console logs, login limits) and use Codex Browser or Playwright, plus live dev-server previews in Mirasim.