-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not connect to internet in WSL 2 #4275
Comments
I have a similar issue. Strangely it worked when I first convert to WSL2, but no longer works after a reboot. For me, the windows hosts generates a WSL ethernet card:
For the WSL ubuntu,
when I try to use I feel the problem is with the netmask, but not sure how to deal with it given the DHCP. |
i also have this issue.When i convert the Ubuntu to wsl version 1, it can connect the Internet. |
try ifconfig down and up |
I'm having this issue too. |
I think the problem is because I had another virtual machine in Hyper-V (Docker For Windows), and there was another network adapter with the name br-25ddfb4f166c and eth0 with the wrong ip. |
The problem happened again. Restarting LxssManager does not resolve. |
Is it possible to inspect WSL2 virtual machine settings? Its not visible in hyper-v console. |
It is not a traditional VM so no. You can see it via hcsdiag.exe and container powershell apis though. |
I had just to uninstall Docker for Windows, restart and the internet started working again in WSL 2! Note that I've uninstalled all virtualization applications last week, except for Hyper-V. |
I had the same issue too. The following resolved my issues:
(For me, ipconfig shows the WSL virtual eth address as 192.168.64.1. Explanation: I noticed that my
versus
Virtual ethernet has subnet mask So the first line changes it to the correct subnet mask.
For the second line, when I ran ip route, I saw:
Which basically means that only the 192.168.64.0/20 range is routable. Hence why
Where the I don't know if this is the 100% correct approach, but it certainly fixes this issue for me. |
Thanks for the info. Anecdotally, it does feel like its related to docker networking. I seem to have found an acceptable workaround. At login, it takes a while for docker to fully initialize. With that, I added a WSL2 process that uses networking at startup which finishes before docker is initialized. Specifically I'm exporting DISPLAY and loading an X window. Working so far. |
@samscott89 |
You might be fine without the second step then. After applying that step, I see:
Where You will probably need (at least) both lines. If the first line is already there, then either you are good to go, or the issue is elsewhere |
@samscott89 the ip address match with the ip in ipconfig but I still cannot ping or use curl. Hope MS address this issue asap because it is a blocker issue that prevent many user from trying and testing WSL 2 |
What's the output of |
ipconfig :
ip a:
ip route:
|
But yeah, fully agree. It seems I might have lucked out that my problem was actually fixable. There are a ton of related networking problems this build. |
@Fubuchi The subnet mask looks wrong on yours as well. Should be 255.255.240.0 corresponding to |
Good call on the subnet mask, I'll get that fixed. |
Steps From @samscott89
|
For the record, this is now fixed for me on build 18932. |
You are right, looks like this is a dupe of #3438 Try this:
Where |
this fixes the issue for me but i have to do that every time i started wsl VM. is the real fix coming soon? |
ah, i just updated to insider 18963. the issue seems to be fixed in this build. |
Confirmed, it was fixed in the latest insider build. |
I'm on 18963 and just ran into this issue, got it working with @samscott89's approach. |
i'm on 18963 and wsl2 and the issue is fixed. are you using wsl1 by any chance? |
As @alekzg just disconnect VPN, close WSL and re-open it. I can't believe this hasn't been fixed yet. Anyone want to work on this fix together and get it pushed? |
I can't believe windows... This needs to be fixed, wasted my whole morning on this. A simple VPN disconnect and reboot of WSL fixes it. wth going on here. |
I don't have any sort of VPN enabled and I'm getting this. |
Have you tried turning off |
For anyone still struggling I have found that allowing incoming traffic on the public profile in the firewall instantly makes DNS resolution work in WSL without having to make any changes to /etc/resolv.conf or having to create /etc/wsl.conf file. Windows Defender Firewall with Advanced Security -> Windows Defender Firewall Properties -> Public Profile -> Inbound Connections set to Allow. My company uses Firewall to block certain ports which causes this issue. When I set this to allow all inbound connections DNS resolution inside WSL starts working instantly. |
This works for me. Many thanks! |
I should note that for me what worked was uninstalling Check Point Endpoint Security. Even though the program itself wasn't running, uninstalling it fixed this. |
The discussions on #4139 ended up fixing this for me. If your organization uses any of the security baseline policies that ship with Intune, firewall rules are likely the culprit as they implement a deny all incoming rule even for local only interfaces. |
You need to make sure that traffic from the network interface in your Linux distro inside WSL2 is routed to the WSL virtual network adapter on your Windows host. If it gets routed anywhere else, you don't get any connectivity to anything outside the Linux vm. Check your routes with VPN connections are notorious for messing that up. I wrote a post about the problem and how you can work around it here: https://janovesk.com/wsl/2022/01/21/wsl2-and-vpn-routing.html |
Thanks, that worked for me! |
In my case, I disabled Hyper-V then it worked finally! |
I have questions regarding the potential solution provided. Basically, I don't know which commands get typed within Windows environment using powershell or cmd versus which get typed within the WSL environment. Could you clarify please?
I ask because the ip route command was not recognized by powershell or cmd, and when typed into the WSL (I had to use sudo, so that's also worth mentioning above for us newbies), I get "RTNETLINK answers: File exists" |
check this solution. It worked for me after trying all the above suggestions. |
Same issue when trying to access network from WSL2. I've uninstalled Docker Desktop on Windows end, rebooted, and it´s working again. |
Step1: |
I can ping; I can nslookup. |
Hi! I've been dealing with this problem for a while, I've tried every solution possible with no results. |
After factory resetting my TP-Link Wireless Router, the problem was solved. Weird! |
In case anyone's coming here from a google search like I did, for me it turns out that a Netgear router in default configuration was blocking WSL2 internet traffic. Switching to a Google WiFi router solved this issue for me. There's probably some setting in the Netgear router config that controls this but I did not investigate further. |
I was getting below error while trying to run wsl --install Solution: I got this error when using Jio mobile hotspot. i changed to airtel hotspot and it works fine. I dont know why it happened, but it works. |
Fixed it by using following content in these files. If files don't exist by default, just create them with given content. # /etc/resolv.conf
nameserver 8.8.8.8 # /etc/wsl.conf
[network]
generateResolvConf = false Shutdown WSL and open it again:
|
I have the similar issue. Then I found I just configured generateResolvConf to false in /etc/wsl.conf:
I update the generateResolvConf to true |
What worked for me was a combination of the above, and in Hyper-V Manager I made sure the switch was set to "Internal Network" (was Private Network). Don't set it to "External Network". I found that creates a bridge and then neither the host nor the guest have internet. |
To my astonishment resetting my router and dsl modem fixed this. I had not had to reset my router/modem in at least 6 months before this. |
Thank you this worked for me!!! |
@BilalAhmed-358 Thanks for the explanation. IN CMD, My IPV4 address is "172.19.0.1", when I run
I got this output "RTNETLINK answers: File exists" my wsl2 is not connecting to internet. btw, that command runs fine: |
For me, it was Norton's Smart Firewall causing this. I disabled it and problem was solved. |
For me is a problem with the router. Resetting works. |
This happen on almost all official WSL distros (suse, debian, ubuntu) . I have not tried kali yet but i think the result will be the same.
This is the report on ubuntu:
Windows build number: 10.0.18932.1000
What you're doing and what's happening:
sudo apt-get update
What's wrong / what should be happening instead:
apt-get update
again. Host name can be resolved now, but get another error:Try disable firewall, still the same error. I only use window defender, no other antivirus.
I convert my distro back to WSL 1 and every network command work fine. The content of resolv.conf in WSL 1 is surprisingly the same as when I overwrite the one in WSL 2
Expected: commands that require internet work as WSL 1
Strace of the failing command, if applicable:
can't, strace has not been installed yet beacause no internet.(I run strace on debian and got the command not found error, so I think ubuntu doesn't have them pre installed too). The log is quite long (3k+ lines) so I put them in a file:apt-strace.log
The text was updated successfully, but these errors were encountered: