WSL: Localhost is not accessible from windows in mirrored mode
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 quit
My .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
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 5
- Comments: 17
I gave up. As much as I tried to pinpoint which one, I never could. For now, I’m simply using NAT mode.
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 entirelyThe 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.
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.