Description
Please fill out the below information:
-
Your Windows build number: (Type
verat a Windows Command Prompt)
Microsoft Windows [Version 10.0.19041.264] -
What you're doing and what's happening: (Copy&paste the full set of specific command-line steps necessary to reproduce the behavior, and their output. Include screenshots if that helps demonstrate the problem.)
I am using an HTTP proxy (ShadowSocks) on windows which is listening on localhost port 1080. Then, I want the command in WSL2 to go through that proxy.

-
What's wrong / what should be happening instead:
curl: (7) Failed to connect to 127.0.0.1 port 1080: Connection refused -
Strace of the failing command, if applicable: (If
some_commandis failing, then runstrace -o some_command.strace -f some_command some_args, and link the contents ofsome_command.stracein a gist here). -
For WSL launch issues, please collect detailed logs.
In WSL1, all things are fine. In WSL2 I could connect to the HTTP proxy through my Windows IP. I believe it is caused by WSL2 running in a separate VM.
Activity
bingzhangdai commentedon May 14, 2020
To simplify the issue, I will show the telnet result,

172.21.80.1is the Windows IP on WSL switch.nunix commentedon May 14, 2020
hi,
the issue here is that while Windows can see the
localhostports of WSL, the inverse in not true by default.The ports forwarding are from WSL to Windows. If you do a
netstat -an | grep 1080on WSL, it should return nothing.However, when you pass it trough the Gateway (WSL switch), it will reach it.
Going forward, you can create a tunnel from Windows to WSL if you need/want to use
localhostin your proxy (see:netsh interface portproxycommand)Hope this helps.
WSL Corsair
bplasmeijer commentedon May 14, 2020
See also #5131
Nuno do Carmo (@nunix) do you see this as default behavior with the portproxy on WSL?
bingzhangdai commentedon May 15, 2020
Thanks for the reply. I notice that many related issues are all about the network between the two systems. I can create a tunnel or proxy for this. But may I know if the WSL team has a specific plan or eta for the network improvement? Thanks.
nunix commentedon May 15, 2020
let's wait for Build (and here I really am like you, I'm waiting on news) and see if something will done.
Bart Plasmeijer (@bplasmeijer) I remember the SSH, actually right now,
netshis what I use for many of my demos.still, I do agree with you that the "reverse forwarding" from Windows to WSL2 would be a great improvement
bplasmeijer commentedon May 15, 2020
cc: Craig Loewen (@craigloewen-msft) Ben Hillis (@benhillis) Hayden Barnes (@sirredbeard)
gencer commentedon May 18, 2020
Nuno do Carmo (@nunix) can you give us an example? For example; I am trying to access
10134port from WSL.10134port is on Windows assigned by Logitech Options application. I would like to access this port from inside WSL.Is it possible to do with the
portproxy? Currently my WSL IP is:172.27.80.1eromoe commentedon May 19, 2020
same problem , we need to use proxy on windows localhost
fatichar commentedon May 27, 2020
In my case, I am unable to connect to a service running on windows on ANY IP. Always the response is:
eromoe commentedon May 28, 2020
Pravin Gajendra Chaudhary (@fatichar) turn off your firewall , it cost me serveral hours to get it out . This is difinitely another big problem
bingzhangdai commentedon May 28, 2020
Actually, what I am looking for is something even more about proxy between WSL2 and Windows. I am expecting similar experiences like WSL1, where WSL and Windows are using the same address (at least users should not be bothered if services on WSL and Windows are listening on different addresses) and follow the same firewall rules.
If the network is not unified, why not use VM directly and using Samba to share the filesystem? WSL1 provide grate convenience compared with VM. 🤔
Am I too greedy? 😂
nunix commentedon May 28, 2020
hi Gencer W. Genç (@gencer) I would suppose it's possible indeed, but on
powershellif you do anetstat -an, on which interface is port 10134 mapped?if it's localhost, then WSL2 cannot reach it indeed, if it's bound to
0.0.0.0then from WSL2 distro, try connecting to the :10134Let me know the output of netstat and I will provide you the command
gencer commentedon May 28, 2020
Nuno do Carmo (@nunix), Unfortunately it binds on localhost as follow:
However, we make it work on SSH/WSL by making vscode extension runing on UI side. This makes us to access localhost port and data.
djfos commentedon Oct 11, 2020
you can access Windows port from WSL2 using your local IP like 192.168.31.66 instead of localhost, though is not elegant
toryano0820 commentedon Nov 15, 2020
I also have experienced this issue when accessing my Windows' Redis instance from my project running in WSL2. End up mapping Nameserver to localhost in
/etc/hosts.You can find Nameserver from
/etc/resolv.conf, it looks like:nameserver 172.18.144.1Then you can add line in
/etc/hostslike:172.18.144.1 localhostCreated a shell script to make life simpler: https://gist.github.com/toryano0820/6ee3bff2474cdf13e70d972da710996a
Not sure yet if there's a downside with this method. But it works!
59 remaining items
pwang2 commentedon Aug 9, 2023
This is a frustrating topic. Exposing all the interfaces from windows via 0.0.0.0 is INSECURE. it would be great and makes most sense to just keep it behave the same as a loopback interface in WSL..
ludobegins commentedon Oct 27, 2023
That moment when you scroll the whole thread since 2020 hoping at this point someone would have a good fix but nope 😂😕
MarcLongoria commentedon Oct 27, 2023
No joke. I've been following this thread since it was opened, hoping someone far more intelligent than me would have solved this by now. Yet here we are lol
obedm503 commentedon Oct 27, 2023
This was fixed in #4619
dons20 commentedon Oct 28, 2023
Update since Major Version 2.0.9
For step 2, you can just do
wsl --updateonly, no need to do the pre-release anymore.Original
Obed (@obedm503) Thanks for pointing it out. Would have never known it was actually being addressed all this time.
Had to take a few steps to get it working on my local environment. Just thought I'd share. The changes are on a pre-release of WSL so it won't be available through regular update paths.
wsl --update; wsl --update --pre-release. You can view the changes of the pre-release versions here: https://github.com/microsoft/WSL/releases.wslconfigfile which is located at%USERPROFILE%in explorer. Add the following:Since getting it enabled, I haven't had a single issue with my localhost being inaccessible. I could safely enable IPV6 again too.
Side note, pre-release v2.0.5 https://github.com/microsoft/WSL/releases/tag/2.0.5 moved the
networkingModesetting from[experimental]to[wsl2].seri0zha commentedon Oct 31, 2023
Keno C (@dons20) thank you so much, it works fine for me. I have spent a lot of time trying to resolve this problem
MarcLongoria commentedon Oct 31, 2023
Awesome to hear! The release mentions it's a window 11 fix. Anyone on Windows 10 to confirm it works for them as well?
Jacksonmills commentedon Nov 15, 2023
This worked for me!
teapot2 commentedon Nov 16, 2023
Keno C (@dons20)
This worked for me too on Windows 11. Thank you!
derharry commentedon Dec 27, 2023
Keno C (@dons20) Thanks! Works for me on W11.
This issue, WSL cannot connect to remote localhost, on my side had to do when the connected WiFi or LAN was set to "public network". On "private network" everything was fine.
With this fix WSL also connects to localhost while in public network. :-)
Vividious commentedon Jan 20, 2024
Keno C (@dons20) cheers mate!
For real, over a year of struggle
mamlzy commentedon May 11, 2024
Works! thank you so much!
misternian commentedon Mar 18, 2025
Keno C (@dons20) save my time. Thank you very much!