Cannot access Windows network port from WSL2 using virtual IP
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
Environment
Windows build number: 10.0.19041.0
Your Distribution version: Ubuntu 10.04
Whether the issue is on WSL 2 and/or WSL 1: WSL2 (Linux version 4.19.104-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Feb 19 06:37:35 UTC 2020)
Steps to reproduce
I just installed a fresh Ubuntu 20.04 LTS on WSL2 for creating this ticket (I experienced the same problem with my Debian on WSL2, so I downgraded that one back to WSL1 as I needed the functionality).
Make sure to have a webserver running on Windows, and you cannot access it with the IP from /etc/resolv.conf in WSL2, even through that should work according to the docs.
In this case, I created a simply NodeJS server on port 8080, which is listening on 0.0.0.0. It is accessible from the entire LAN on 192.168.1.24 (local IP).
Now, if you want to access it from WSL2, using the nameserver (172.21.48.1 here, or virtual IP) as suggested in the article, it unfortunately does not respond at all. Using localhost doesn't work either (as expected), but using the direct IP address does work.
Below is a screenshot of my test: top-left is the WSL2 Ubuntu, top-right is Powershell on Windows running the actual server. De two browser windows on the bottom are run on the host machine, demonstrating the webserver responds to both localhost and the external IP (external IP access was also tested from another machine on the LAN, that works fine).

Expected behavior
I would expect to either
- see the virtual IP behave as described in the documentation
- see the local IP in
/etc/resolv.conf(but that breaks DNS resolving at this time) - see the local IP in some other file
The latter would be useful for scripting.
Actual behavior
Well, it isn't working as I would have hoped😄
P.S. While working on this, I also managed to break DNS resolving completely. This was probably related to me resetting the Windows firewall (for testing), as it was fixed after rebooting.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the WSL2 networking setup with a Windows web server listening on 0.0.0.0:8080 and test access through the nameserver address from /etc/resolv.conf, localhost, and the host's local IP. Investigate how WSL2 exposes the Windows host address and verify the documented virtual-IP behavior. Done means the virtual IP works as documented or a reliable scriptable host-IP alternative is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- networking, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100