WSL: WSL2 cannot connect to Windows Host as a server
Please use the following bug reporting template to help produce issues which are actionable and reproducible, including all command-line steps necessary to induce the failure condition. Please fill out all the fields! Issues with missing or incomplete issue templates will be closed.
If you have a feature request, please post to the UserVoice.
If this is a console issue (a problem with layout, rendering, colors, etc.), please post to the console issue tracker.
Important: Do not open GitHub issues for Windows crashes (BSODs) or security issues. Please direct all Windows crashes and security issues to secure@microsoft.com. Ideally, please configure your machine to capture minidumps, repro the issue, and send the minidump from "C:\Windows\minidump".
Please fill out the below information:
-
Your Windows build number: (Type
verat a Windows Command Prompt) Microsoft Windows [Version 10.0.18932.1000] -
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 screen shots if that helps demonstrate the problem.)
- Start any server program, e.g. sql server, postgres, or a simple django program with runserver from the windows host.
- Bind the server program with the windows host IP address (vEthernet - WSL).
- Try to connect to the server program using the windows host IP address from WSL2.
Will get a timeout. Even trying to ping the windows host IP doesnt work - although traceroute www.google.com would successfully find a route.
-
What’s wrong / what should be happening instead: See above.
-
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). N/A -
For WSL launch issues, please collect detailed logs.
See our contributing instructions for assistance.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 14
- Comments: 16 (1 by maintainers)
I’m getting the same issue! In my case I’m running minikube in windows 10 pro and trying to access it from WSL 2 kubectl … Please help!
Tried without wirewall and it still doesn’t work!
Doesn’t work for me, tried to disable firewall, still got connection timed out error
So, I got it fixed. I just needed to add the port I’m trying to access on the host to the firewall.
I struggled with this for a while, but ended up managing to get it.
First, setting the host to listen on 0.0.0.0 (or your network interface’s IP address. if you go to cmd and type
ipconfigyou can find your interface IP address there) Second, Adding the Windows Firewall rule for the port you’re trying to access. Third, and this one caught me for a while. Edit that rule you’ve just created and make sure Advanced->Edge Traversal is enabled. Fourth, the address you need to connect to within wsl2 needs to be your interface’s IP address (the one found from ipconfig) and not localhost or 127.0.0.1.The third point especially I hadn’t seen elsewhere, but was the last step needed for mine to work. Hopefully this helps!
Referring to this post in another thread. https://github.com/microsoft/WSL/issues/4150#issuecomment-504209723
This is an ok workaround for me, where I needed to connect to SQL server on host computer from WSL2. AFAIK Microsoft is still working on a permanent fix to forward localhost in WSL to host machine.
This is the script that I run on boot
I then connect to the IPv4 address from Ethernet adapter vEthernet (WSL) in Windows from my application in WSL.
I’m still seeing this - even if I disable the firewall entirely.
If I use the wireless network’s address and bind to that interface on windows I can access it from wsl2 through that network, but I want to be able to do it through the local network between the wsl2 guest and the windows host rather than open up a public port.
This is despite seeing this on the windows host routes:
And this on the linux host routes:
So logically they should both be on the same network, but seemingly traffic can only flow in one direction.