Repository navigation
Closed
Labels
Description
Windows Version
10.0.22631.3155
WSL Version
2.0.14.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
5.15.133.1-1
Distro Version
Debian 11
Other Software
No response
Repro Steps
Run a Flask app in WSL and want to view it via Windows chrome.
10.12.13.129 is the IP addr of both Windows and WSL thanks to newest WSL 2.0 update
~ > python3 server.py
* Serving Flask app 'Order Statistics'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:8000
* Running on http://10.12.13.129:8000
Press CTRL+C to quitMy .wslconfig:
[experimental]
autoMemoryReclaim=dropcache
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true
sparseVhd=true
hostAddressLoopback=true
[wsl2]
localhostforwarding=true
[network]
generateResolvConf = true
generateHosts = true
[boot]
systemd=true
ifconfig in WSL:
~ ❯ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:73:05:3d:d4 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.12.13.129 netmask 255.255.255.0 broadcast 10.12.13.255
inet6 fe80::9d37:c517:1515:fa5e prefixlen 64 scopeid 0x20<link>
ether ec:63:d7:ad:ae:a3 txqueuelen 1000 (Ethernet)
RX packets 238 bytes 16645 (16.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 51 bytes 5742 (5.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 46 bytes 4093 (3.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 46 bytes 4093 (3.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
loopback0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:15:5d:4e:8d:b7 txqueuelen 1000 (Ethernet)
RX packets 18 bytes 1208 (1.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 115 bytes 19254 (18.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ifconfig -all in Windows:
PS C:\Users\jianqiao.chen> ipconfig -all
Windows IP 配置
主机名 . . . . . . . . . . . . . : DESKTOP-P30B40R
主 DNS 后缀 . . . . . . . . . . . : xx.com.cn
节点类型 . . . . . . . . . . . . : 混合
IP 路由已启用 . . . . . . . . . . : 否
WINS 代理已启用 . . . . . . . . . : 否
DNS 后缀搜索列表 . . . . . . . . : xx.com.cn
以太网适配器 以太网:
媒体状态 . . . . . . . . . . . . : 媒体已断开连接
连接特定的 DNS 后缀 . . . . . . . :
描述. . . . . . . . . . . . . . . : Intel(R) Ethernet Connection (10) I219-V
物理地址. . . . . . . . . . . . . : 84-A9-38-57-23-2B
DHCP 已启用 . . . . . . . . . . . : 否
自动配置已启用. . . . . . . . . . : 是
以太网适配器 以太网 4:
连接特定的 DNS 后缀 . . . . . . . :
描述. . . . . . . . . . . . . . . : VirtualBox Host-Only Ethernet Adapter
物理地址. . . . . . . . . . . . . : 0A-00-27-00-00-17
DHCP 已启用 . . . . . . . . . . . : 否
自动配置已启用. . . . . . . . . . : 是
本地链接 IPv6 地址. . . . . . . . : fe80::2cbb:49ff:8d9f:62c0%23(首选)
IPv4 地址 . . . . . . . . . . . . : 192.168.56.1(首选)
子网掩码 . . . . . . . . . . . . : 255.255.255.0
默认网关. . . . . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 1091174439
DHCPv6 客户端 DUID . . . . . . . : 00-01-00-01-2C-27-82-88-84-A9-38-57-23-2B
TCPIP 上的 NetBIOS . . . . . . . : 已启用
未知适配器 本地连接:
媒体状态 . . . . . . . . . . . . : 媒体已断开连接
连接特定的 DNS 后缀 . . . . . . . :
描述. . . . . . . . . . . . . . . : TAP-Windows Adapter V9 for OpenVPN Connect
物理地址. . . . . . . . . . . . . : 00-FF-F8-29-5D-19
DHCP 已启用 . . . . . . . . . . . : 否
自动配置已启用. . . . . . . . . . : 是
无线局域网适配器 本地连接* 9:
媒体状态 . . . . . . . . . . . . : 媒体已断开连接
连接特定的 DNS 后缀 . . . . . . . :
描述. . . . . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter
物理地址. . . . . . . . . . . . . : EC-63-D7-AD-AE-A4
DHCP 已启用 . . . . . . . . . . . : 是
自动配置已启用. . . . . . . . . . : 是
无线局域网适配器 本地连接* 10:
媒体状态 . . . . . . . . . . . . : 媒体已断开连接
连接特定的 DNS 后缀 . . . . . . . :
描述. . . . . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter #2
物理地址. . . . . . . . . . . . . : EE-63-D7-AD-AE-A3
DHCP 已启用 . . . . . . . . . . . : 否
自动配置已启用. . . . . . . . . . : 是
以太网适配器 VMware Network Adapter VMnet1:
连接特定的 DNS 后缀 . . . . . . . :
描述. . . . . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet1
物理地址. . . . . . . . . . . . . : 00-50-56-C0-00-01
DHCP 已启用 . . . . . . . . . . . : 是
自动配置已启用. . . . . . . . . . : 是
本地链接 IPv6 地址. . . . . . . . : fe80::eee:e9f5:bdda:16c4%13(首选)
IPv4 地址 . . . . . . . . . . . . : 192.168.253.1(首选)
子网掩码 . . . . . . . . . . . . : 255.255.255.0
获得租约的时间 . . . . . . . . . : 2024年2月18日 16:53:26
租约过期的时间 . . . . . . . . . : 2024年2月18日 17:53:37
默认网关. . . . . . . . . . . . . :
DHCP 服务器 . . . . . . . . . . . : 192.168.253.254
DHCPv6 IAID . . . . . . . . . . . : 1174425686
DHCPv6 客户端 DUID . . . . . . . : 00-01-00-01-2C-27-82-88-84-A9-38-57-23-2B
TCPIP 上的 NetBIOS . . . . . . . : 已启用
以太网适配器 VMware Network Adapter VMnet8:
连接特定的 DNS 后缀 . . . . . . . :
描述. . . . . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet8
物理地址. . . . . . . . . . . . . : 00-50-56-C0-00-08
DHCP 已启用 . . . . . . . . . . . : 是
自动配置已启用. . . . . . . . . . : 是
本地链接 IPv6 地址. . . . . . . . : fe80::3bad:4191:8da3:db71%16(首选)
IPv4 地址 . . . . . . . . . . . . : 192.168.133.1(首选)
子网掩码 . . . . . . . . . . . . : 255.255.255.0
获得租约的时间 . . . . . . . . . : 2024年2月18日 16:53:26
租约过期的时间 . . . . . . . . . : 2024年2月18日 17:53:23
默认网关. . . . . . . . . . . . . :
DHCP 服务器 . . . . . . . . . . . : 192.168.133.254
DHCPv6 IAID . . . . . . . . . . . : 1207980118
DHCPv6 客户端 DUID . . . . . . . : 00-01-00-01-2C-27-82-88-84-A9-38-57-23-2B
主 WINS 服务器 . . . . . . . . . : 192.168.133.2
TCPIP 上的 NetBIOS . . . . . . . : 已启用
无线局域网适配器 WLAN:
连接特定的 DNS 后缀 . . . . . . . : xx.com.cn
描述. . . . . . . . . . . . . . . : Intel(R) Wi-Fi 6 AX201 160MHz
物理地址. . . . . . . . . . . . . : EC-63-D7-AD-AE-A3
DHCP 已启用 . . . . . . . . . . . : 是
自动配置已启用. . . . . . . . . . : 是
本地链接 IPv6 地址. . . . . . . . : fe80::9d37:c517:1515:fa5e%20(首选)
IPv4 地址 . . . . . . . . . . . . : 10.12.13.129(首选)
子网掩码 . . . . . . . . . . . . : 255.255.255.0
获得租约的时间 . . . . . . . . . : 2024年2月18日 16:53:27
租约过期的时间 . . . . . . . . . : 2024年2月20日 8:48:03
默认网关. . . . . . . . . . . . . : 10.12.13.254
DHCP 服务器 . . . . . . . . . . . : 10.12.13.127
DHCPv6 IAID . . . . . . . . . . . : 166486999
DHCPv6 客户端 DUID . . . . . . . : 00-01-00-01-2C-27-82-88-84-A9-38-57-23-2B
DNS 服务器 . . . . . . . . . . . : 10.12.13.127
8.8.8.8
TCPIP 上的 NetBIOS . . . . . . . : 已启用
I've tried to disable Windows firewall but still cannot access to localhost
Expected Behavior
curl http://localhost:8000is accessiblecurl http://10.12.13.129:8000is accessible
Actual Behavior
In Windows:
curl http://localhost:8000is not accessiblecurl http://10.12.13.129:8000is accessible
In WSL:
curl http://localhost:8000is accessiblecurl http://10.12.13.129:8000is accessible
Diagnostic Logs
No response
Reacted by Yuns, Kohey, Sergey Nevmerzhitsky, Paul Friedrich, lachlanj-sportsbet and adam li
Activity
Slamik commentedon Feb 27, 2024
The same. From today. Yesterday was everything ok.
domain.com points to 127.0.0.1 in hosts.
When access from another WSL2 instance - ok.
From Windows - timeout.
simon-weber commentedon Feb 29, 2024
Same here. It happened some time this week I think.
Switching to NAT mode fixes it, but that also makes the outbound internet connection is too unstable for me to use (it usually drops within a minute).
Here's some things I found in similar networking issues that had no effect:
hostAddressLoopbacktrue/falsefirewall=falseand disabling hyper-v firewall entirelysimon-weber commentedon Feb 29, 2024
The best workaround I've found for web dev is to run a browser inside wsl2 instead.
rbruhn commentedon Mar 3, 2024
Simon Weber (@simon-weber) Thanks for the NAT solution. I've been working on this for days trying to figure out why it suddenly stopped working. I have a git push on the 24th. On the 27th, Windows updated to version 23H2.
Edit: I have another Windows 11 computer that is working. I performed all the current Window updates and WSL is still working correctly. Meaning, WSL is mirrored and I can reach domain names. So it's not the update.
I took a look at the differences between the two and it appears the non-working is coming up short when creating the network connections. Not sure why or how to fix it.
WSL Mirrored Working: https://gist.github.com/rbruhn/348eaadddedf415472ab6aaf0823a572
WSL Mirrored Not Working: https://gist.github.com/rbruhn/c05f72cf9fdbe000852a080bf725ff14
rbruhn commentedon Mar 4, 2024
I exported my working version of ubuntu 20.04 and moved it over to the other computer. Removed the one that wasn't working, then imported. I got everything up and working. Then, I performed "apt update && apt upgrade"
The upgrade broke it again. So, something in the upgrading of Ubuntu is breaking WSL.
deadcoder0904 commentedon Mar 4, 2024
I'm not sure if I'm using mirrored mode but I have nothing in my
.wslconfig.I'd love for
localhostto work. Currently, I have to point it to0.0.0.0which is inconvenient. It took an insane amount of my time withredisservice in docker. Even there I had to changeREDIS_HOST=localhosttoREDIS_HOST=0.0.0.0which is annoying..Edit: Even
0.0.0.0didn't work. I had to use my ip to get redis working.Another Edit: Even my ip didn't work. I gues my error was due to this which I feel is unrelated but idk.
Please make this simple. Its annoying to use Windows because of these random issues.
Slamik commentedon Mar 4, 2024
True. I did an apt upgrade before.
Slamik commentedon Mar 4, 2024
I filter out updates history not related to Ubuntu. The list of packages that may cause the issue:
UPD.
Downgrade all these packages but didn't achieve nothing.
rbruhn commentedon Mar 4, 2024
Slamik These are the packages that show in mine before upgrade. When I have time, I might go through them one by one.
yunsii commentedon Mar 26, 2024
Any progress here?
rbruhn commentedon Mar 26, 2024
I gave up. As much as I tried to pinpoint which one, I never could. For now, I'm simply using NAT mode.
Slamik commentedon Mar 28, 2024
The same :)
cveld commentedon Jun 21, 2024
Just recently access from Windows to a WSL service stopped working when using
mirroredmode. Neither using the full eth ip yields results. It yields in a long time-out. Longer than if I curl to a port that is not used. 20 secs vs 2 secs.I also reverted to NAT mode. But now I can't access Windows services from WSL through localhost anymore. Ideally mirrored mode should just work. I noticed that I have 3 eth adapters with eth0 being the correct one. Maybe wsl is not connecting to the correct eth adapter? Also see #10884
Soappyooo commentedon Jun 29, 2024
A possible solution for me is #11600 (comment), turning on the mobile hotspot of Windows makes localhost services on Windows accessible for WSL.
shigenobuokamoto commentedon Jun 30, 2024
in case accessing from Windows, does doing the following make any difference?
CatalinFetoiu commentedon Jul 26, 2024
Hi. Can you please collect networking logs by following the instructions below?
https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues
RadicalAcronym commentedon Feb 6, 2025
I'm having a similar problem. localhost from win (client) to wsl (server) does not work sometimes.
When, in wsl, I start a server with:
In Windows:
http://localhost:8000is accessibleBut, when, in wsl, I start a server with:
In Windows:
http://localhost:8000is not accessibleHere's my
.wslconfigand my `wsl.config
If I happen to change to
networkingMode=NAT, then bothpython3 -m http.server 8000anddocker run --rm --name docker-nginx -p 8000:8000 nginxwork (separately , not at the same time) -- meaning, in Windows ``http://localhost:8000` is accessible with either serverparkging commentedon Feb 12, 2026
Has anyone solved this problem?
vasabi-root commentedon May 15, 2026
parkging (@parkging)
Seems weird, but using
127.0.0.1in Windows directly instead oflocalhostsolved my problem in mirrored networkingMode.I have gRPC server in WSL's
localhost. I was trying to connect to it from Kreya from the Windows host. Iflocalhostis used in Windows, every sended request is received in WSL after 21 sec (so it was not "not accessible", but very slow). If127.0.0.1is used, the delay is gone completely. Maybe here is some IPv6 stuff, idk, but it works for me.