WSL: Networking mirrored can't access to windows by 127.0.0.1:port with WSL2
Windows Version
Microsoft Windows [版本 10.0.22631.3296]
WSL Version
2.1.5.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
5.15.146.1-microsoft-standard-WSL2
Distro Version
ubuntu 20.04
Other Software
Docker desktop was uninstalled from the windows system.
Repro Steps
Information
My laptop’s IP is 192.168.0.102 in WLAN.
Is was worked for me before. But after I reset my system, I can not make it work again.
- Start a clash app with port
7890 - Go into the wsl environment
- Execute command
telnet 127.0.0.1 7890 - Not connected
First
.wslconfig
[wsl2]
networkingMode=mirrored
commands and result
detail
msojocs@DESKTOP-1TV4OAG:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff
inet6 fe80::9c5b:a645:98b4:bfc2/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether da:80:83:b3:d6:cb brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:c0:00:01 brd ff:ff:ff:ff:ff:ff
inet6 fe80::de9f:1113:2891:d898/64 scope link noprefixroute
valid_lft forever preferred_lft forever
5: loopback0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:5d:e1:6c:93 brd ff:ff:ff:ff:ff:ff
inet6 fe80::3b9f:eb69:8d5e:9e71/64 scope link noprefixroute
valid_lft forever preferred_lft forever
6: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether d8:80:83:b3:d6:cb brd ff:ff:ff:ff:ff:ff
inet 192.168.0.102/24 brd 192.168.0.255 scope global noprefixroute eth3
valid_lft forever preferred_lft forever
inet6 fe80::7df1:6f90:3370:4cd1/64 scope link nodad noprefixroute
valid_lft forever preferred_lft forever
7: eth4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether fa:80:83:b3:d6:cb brd ff:ff:ff:ff:ff:ff
8: eth5: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether ea:80:83:b3:d6:cb brd ff:ff:ff:ff:ff:ff
msojocs@DESKTOP-1TV4OAG:~$ telnet 127.0.0.1 7890
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
msojocs@DESKTOP-1TV4OAG:~$ telnet 192.168.0.102 7890
Trying 192.168.0.102...
telnet: Unable to connect to remote host: Connection refused
msojocs@DESKTOP-1TV4OAG:~$
Second
.wslconfig
[wsl2]
networkingMode=mirrored
[experimental]
hostAddressLoopback=true
commands and result
detail
msojocs@DESKTOP-1TV4OAG:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff
inet6 fe80::9c5b:a645:98b4:bfc2/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether da:80:83:b3:d6:cb brd ff:ff:ff:ff:ff:ff
inet6 fe80::bf84:bc17:2e88:c5c0/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:c0:00:01 brd ff:ff:ff:ff:ff:ff
inet6 fe80::de9f:1113:2891:d898/64 scope link noprefixroute
valid_lft forever preferred_lft forever
5: loopback0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:5d:e1:6c:93 brd ff:ff:ff:ff:ff:ff
inet6 fe80::3b9f:eb69:8d5e:9e71/64 scope link noprefixroute
valid_lft forever preferred_lft forever
6: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether d8:80:83:b3:d6:cb brd ff:ff:ff:ff:ff:ff
inet 192.168.0.102/24 brd 192.168.0.255 scope global noprefixroute eth3
valid_lft forever preferred_lft forever
inet6 fe80::7df1:6f90:3370:4cd1/64 scope link nodad noprefixroute
valid_lft forever preferred_lft forever
7: eth4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether fa:80:83:b3:d6:cb brd ff:ff:ff:ff:ff:ff
8: eth5: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether ea:80:83:b3:d6:cb brd ff:ff:ff:ff:ff:ff
msojocs@DESKTOP-1TV4OAG:~$ telnet 127.0.0.1 7890
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
msojocs@DESKTOP-1TV4OAG:~$ telnet 192.168.0.102 7890
Trying 192.168.0.102...
Connected to 192.168.0.102.
Escape character is '^]'.
Expected Behavior
The command telnet 127.0.0.1 7890 can success.
Actual Behavior
The command telnet 127.0.0.1 7890 is failed.
Diagnostic Logs
Log
Collected log
Steps:
- execute
wsl --shutdown - execute
.\collect-networking-logs.ps1 - execute
wsl - execute
curl 127.0.0.1:7890 - execute
telnet 127.0.0.1 7890 - execute
telnet 192.168.0.102 7890
WslNetworkingLogs-2024-03-16_15-43-33.zip
Other
cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 180.76.76.76
nameserver 223.6.6.6
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 23 (1 by maintainers)
Try executing the command
followed by running wsl.exe --shutdown in PowerShell, and then restart WSL again.
I tried disabling every service until I reached network-manager.service, and finally, the mirrored functionality started working properly. It took me a significant amount of time to figure this out.
Hi I’m an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Open similar issues:
Closed similar issues:
Failed to disable unit: Unit file network-manager.service does not exist.😢
Unlucky😢😢, it also show:
Failed to disable unit: Unit file NetworkManager.service does not exist.Solved my problem, thanks
Similar issue. It works for me. Thanks so much!
I did not changed anything and a couple of weeks ago all worked well.