By Leo Lin, Product Manager at FlashIP, Singapore. Author works on FlashIP.
Windows has a proxy set, the browser works, and then curl or pip install inside Ubuntu on WSL 2 times out. Or the opposite: WSL picks up a proxy you never set in Linux at all. Both come from the same place. WSL 2 runs Linux in a lightweight VM with its own network stack, and it has its own rules for copying (or not copying) the Windows proxy into Linux. This guide covers the three setups you will meet: automatic proxy from Windows, mirrored networking with a local proxy app, and manual settings for the default NAT mode. proxy.example.net:8000 and USER:PASS are placeholders.
Step 1: know which networking mode you are in
Everything below depends on networkingMode in %UserProfile%\.wslconfig (the global WSL 2 config file on the Windows side, not inside the distro). The file doesn't exist by default. The mode is NAT unless you change it. Microsoft documents these values: none, nat, mirrored, consomme, and bridged (deprecated). Mirrored mode requires Windows 11 22H2 or later.
[wsl2] networkingMode=mirrored autoProxy=true Changes apply only after the WSL VM fully stops. Microsoft calls this the "8 second rule". The quick way is to run this from PowerShell:
wsl --shutdown Then open your distro again.
Step 2: let autoProxy copy the Windows proxy
On Windows 11, autoProxy defaults to true. The docs describe it as enforcing "WSL to use Windows' HTTP proxy information". So if you set a proxy in Windows, WSL sets it in Linux too. Check what you actually got:
env | grep -i -E '_proxy|WSL_PAC_URL' Looking at the WSL source code shows what to expect. WSL writes both lowercase and uppercase http_proxy, https_proxy and no_proxy, because some Linux tools read one case and some read the other. If Windows uses a PAC script, WSL also sets WSL_PAC_URL. Linux tools don't read that variable themselves. It just makes the URL available, so you can fetch the PAC file and point your tools at the right proxy.
Two practical notes:
- Timing. WSL waits for the Windows proxy lookup when the VM starts. The wait is set by
initialAutoProxyTimeoutin the[experimental]section, 1000 ms by default. If the lookup finishes later, the docs say you have to restart the WSL instance to pick it up. If the variables are sometimes missing after boot, raise this value. - Turning it off. If you want Linux to have its own proxy settings, or none, set
autoProxy=falseunder[wsl2]and runwsl --shutdown.
Step 3: a proxy app on Windows localhost needs mirrored mode
A common setup is a local proxy client on Windows listening on 127.0.0.1:7890 or similar, with Windows pointed at it. In NAT mode that address means nothing inside Linux: 127.0.0.1 in the VM is the VM itself. WSL's code rejects loopback proxy addresses when it isn't in mirrored mode. Instead of copying the setting, it shows this warning:
A localhost proxy configuration was detected but not mirrored into WSL. This proxy address is not supported by the current networking configuration.
The fix is networkingMode=mirrored. Microsoft's networking page says that in mirrored mode Linux can reach Windows servers at 127.0.0.1. The IPv6 loopback ::1 is not supported, so point the Windows proxy at 127.0.0.1, not [::1]. After wsl --shutdown, the variables from autoProxy should work as they are:
curl -sS -o /dev/null -w '%{http_code}\n' https://example.com Step 4: manual settings for NAT mode
If you stay on NAT, or you turned autoProxy off, set the variables yourself. There are two cases.
The proxy is a remote host (a corporate gateway or a provider endpoint). Linux can reach it directly, so set it like on any Linux machine, for example in ~/.bashrc:
export http_proxy=http://USER:PASS@proxy.example.net:8000 export https_proxy=$http_proxy export no_proxy=localhost,127.0.0.1,::1 export HTTP_PROXY=$http_proxy HTTPS_PROXY=$https_proxy NO_PROXY=$no_proxy The proxy runs on the Windows host. In NAT mode, Microsoft's networking page shows how to find the Windows host's IP from inside Linux:
WIN_HOST=$(ip route show | grep -i default | awk '{ print $3}') export http_proxy=http://$WIN_HOST:7890 https_proxy=http://$WIN_HOST:7890 Two catches, both from the same page. First, connections over that IP count as LAN connections. The Windows app must accept them, which usually means a "listen on all interfaces" or "allow LAN" option, or binding to 0.0.0.0 instead of 127.0.0.1. Second, Windows Firewall rules apply, and the Hyper-V firewall is on by default with WSL 2.0.9 or later, so you may need a rule for the proxy port. The host IP can also change after a restart, which is why the snippet looks it up each time instead of hard-coding it.
Things that still bypass the variables
Shell variables only reach programs that inherit them. sudo normally drops them because of env_reset. Tools with their own config files (apt, Docker, Git, npm) may need their own settings. If your distro runs systemd, services don't read ~/.bashrc either. These rules are the same as on any Linux machine, so the usual per-layer fixes work inside WSL too.
Wrapping up
When a proxy misbehaves in WSL 2, check the networking mode first. NAT plus a localhost proxy on Windows won't work. Mirrored mode or an explicit host IP will. After that, decide whether autoProxy or your own variables should be in charge, and confirm with env and one curl. Any standard HTTP or SOCKS5 endpoint works in these setups, including FlashIP's proxies (www.flaship.com).

