Guides ·
Claude Code in WSL, Docker or on a remote server: which IP does it actually use?
Claude Code only reads proxy variables (https_proxy and friends) from the environment it is running in. Inside WSL 2, a Docker container or on a remote server, the proxy you set up on Windows or macOS is not inherited: with no variable set, it connects directly from that environment's own network, and on a remote server the exit is simply the server's IP. Below is how to set the address in each case and how to confirm it (checked against the official docs on October 6, 2026).
My laptop uses the proxy, so why does Claude Code in WSL or Docker go direct?
Because each of them has its own environment and its own network. Per the Claude Code network configuration docs, Claude Code uses the first one set of https_proxy, HTTPS_PROXY, http_proxy, HTTP_PROXY; it does not support SOCKS proxies; and it reads the variables once at startup. A shell inside WSL, a container or a server does not inherit your terminal's variables or your OS proxy settings, so you have to set them there.
The second trap is 127.0.0.1. In WSL 2 (default mode) and in a container it means WSL or the container itself, not your computer, so copying http://127.0.0.1:port from your host will not reach the proxy.
| Environment | Proxy address | Exit if unset |
|---|---|---|
| Local terminal | 127.0.0.1:port | Your network |
| WSL 2 (NAT, default) | Windows host IP | Your network |
| WSL 2 (mirrored) | 127.0.0.1:port | Your network |
| Docker container | host.docker.internal:port (Docker Desktop) | The host's network |
| Remote server | A proxy the server can reach | The server's IP |
How do I make Claude Code in WSL use the proxy on Windows?
It depends on the WSL networking mode. Per Microsoft's WSL networking docs, the default is NAT.
NAT (default): use the Windows host IP. Microsoft's command for it, combined into the proxy variables (replace the port with your proxy app's HTTP or mixed port):
WIN=$(ip route show | grep -i default | awk '{ print $3}')
export https_proxy=http://$WIN:7890 http_proxy=http://$WIN:7890
The same page notes that connections over this address are treated as coming from the LAN, so the proxy app on Windows must accept LAN connections (often labelled "Allow LAN"). If it only listens on 127.0.0.1, WSL cannot reach it.
Mirrored: on Windows 11 22H2 and later you can set networkingMode=mirrored under [wsl2] in .wslconfig. WSL can then reach Windows services at 127.0.0.1, so the address is the same as on Windows.
autoProxy: also Windows 11 22H2 and later. autoProxy=true under [wsl2] makes WSL use the Windows HTTP proxy settings. Either way, run env | grep -i proxy inside WSL to see what Claude Code will actually read.
How do I set it inside a Docker container?
Claude Code in a container only sees the container's environment. Three common ways:
- Pass it at run time:
docker run -e https_proxy=http://host.docker.internal:7890 …. Per the Docker Desktop docs,host.docker.internalresolves to the host's internal IP and is meant for reaching services on the host. ~/.docker/config.json: sethttpsProxyandhttpProxyunderproxies.default, and Docker setsHTTPS_PROXY/https_proxyand friends in new containers and builds (Docker docs). Existing containers are not affected.- Dev Containers: put the variables in
containerEnvindevcontainer.json, the same mechanism the Claude Code dev container docs use.
Two easy misses: Docker's allProxy maps to ALL_PROXY, which Claude Code does not read, so fill in httpsProxy; and Docker Desktop accepts SOCKS5 proxies in its settings, but Claude Code does not support SOCKS, so give it an HTTP proxy. If you use the egress firewall (init-firewall.sh) from Anthropic's reference container, allow the proxy address too.
On a remote server, whose IP does Anthropic see?
The server's. Once you SSH in, Claude Code runs on the server with the server's network and the server's environment variables; whether your laptop has a proxy is irrelevant. So the exit to check is the server's: it needs to be in one of Anthropic's supported regions, and a cloud server's exit normally belongs to a hosting network, which our check labels "Datacenter".
To have Claude Code on the server use your local proxy instead, use SSH remote forwarding. Per the OpenSSH manual, -R forwards connections to a port on the server back to the local side:
ssh -R 7890:127.0.0.1:7890 your-server export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890
Run the first line on your machine and the second inside the server session. Requests then leave through your local proxy, and stop working when the SSH session closes.
Background sessions started with --bg or claude agents may not inherit your current shell. The official docs recommend putting proxy variables in the env block of ~/.claude/settings.json, which every background session reads.
How do I confirm where Claude Code actually exits?
Inside WSL, the container or the server, in the same shell you run Claude Code from:
curl -sL ipjudge.org/en/cc | bash
The script applies Claude Code's own rules (only the four proxy variables, no SOCKS, no ALL_PROXY) to work out the proxy it will use, asks api.anthropic.com which IP it sees, and compares that with the direct exit. Read-only: it installs, changes and uploads nothing.
You can also run /status inside Claude Code and look at the Proxy row; a value it cannot parse is marked invalid and ignored.
FAQ
curl works in WSL, but Claude Code still goes direct. Why? Usually only ALL_PROXY is set, or the proxy is written as socks5://. curl accepts both; Claude Code accepts neither. Use https_proxy=http://….
Why does 127.0.0.1:7890 fail inside a container? Inside the container, 127.0.0.1 is the container. On Docker Desktop use host.docker.internal:7890; if that still fails, check whether the host proxy only listens on 127.0.0.1.
I changed the variables, but the running session didn't notice. Claude Code reads them once at startup, so restart it. For background sessions, set them in ~/.claude/settings.json.
Does a remote server need a proxy at all? Not necessarily. If the server sits in a supported region, Claude Code can use its exit directly. Run the script above on the server to see what type of network the platforms will see.
I enabled mirrored mode. Do I still need the variables? Yes. Mirrored mode only lets 127.0.0.1 reach Windows; Claude Code still only follows the variables. With autoProxy=true, check env | grep -i proxy to see whether they were set for you.
Anthropic’s terms expect you to use its services from a supported region. Accounts that get around the restriction from elsewhere may be limited or disabled.
Related: Claude Code exit check · Claude check · Why your terminal goes direct · Claude Code 403 checklist · Residential vs datacenter IPs
Which kind of IP do you have?
Check which exit my terminal uses