Skip to content
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

WSL2 cannot connect to the internet after upgrading from WSL1 (TRIED EVERYTHING!) #6016

Closed
Lumenbolt opened this issue Oct 2, 2020 · 17 comments
Labels

Comments

@Lumenbolt
Copy link

Lumenbolt commented Oct 2, 2020

Hi,

I'm currently running Windows 10 (version 2004 build 19041.508). WSL2 just doesn't connect to the network. I have tried three different distributions (Debian, Ubuntu 20.04 LTS & openSUSE Leap 15.2) and neither of them could connect to the internet by running either sudo apt upgrade or sudo zypper up (in case of opensuse).

The following is shown when i run sudo apt update on debian:

Err:1 http://deb.debian.org/debian buster InRelease Temporary failure resolving 'deb.debian.org' Err:2 http://security.debian.org/debian-security buster/updates InRelease Temporary failure resolving 'security.debian.org' Err:3 http://ftp.debian.org/debian buster-backports InRelease Temporary failure resolving 'ftp.debian.org' Err:4 http://deb.debian.org/debian buster-updates InRelease Temporary failure resolving 'deb.debian.org' Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving 'deb.debian.org' W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Temporary failure resolving 'deb.debian.org' W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Temporary failure resolving 'security.debian.org' W: Failed to fetch http://ftp.debian.org/debian/dists/buster-backports/InRelease Temporary failure resolving 'ftp.debian.org' W: Some index files failed to download. They have been ignored, or old ones used instead.

In response to this, I looked up for forums on such and did all the following (doing neither helped):

--> Editing resolv.conf to point to a functioning nameserver for the duration of the session. (As mentioned in #5256 (comment))

Also, sudo ping 8.8.8.8 returned the following error: connect: Network is unreachable

--> I had protonVPN installed in my pc, i went ahead and uninstalled it (including the network drivers it came with)

--> Uninstalled all Hyper-V components, uninstalled all TAP based networking by uninstalling VPN clients i have installed (as mentioned in #5256 (comment))

--> Completely disabled Windows Firewall & Windows Defender Firewall

Doing all of them got me nowehere, whatsoever! WSL1 was doing great, but i need the features of WSL2 to let it interact with windows better than wsl1.
Looking through the issues in this github repo, a lot if has to do with WSL2's network connectivity. A kind request to the developers to fix the general network issues in WSL2 asap.

Any beginner-friendly help to this issue would be great! :)

@therealkenc
Copy link
Collaborator

Please collect WSL logs and post the backlink to the feedback item here. Also please identify any third-party networking software that has been installed on Windows.

@allexlima
Copy link

same problem here =(
I'm trying this -> https://support.microsoft.com/en-us/help/4577063/windows-10-update-kb4577063

@Lumenbolt
Copy link
Author

same problem here =(
I'm trying this -> https://support.microsoft.com/en-us/help/4577063/windows-10-update-kb4577063

Let me know if it worked...I nearly never update to preview builds but i might this time if it has the issue fixed.

@agualdron
Copy link

You can also check if the wsl is connected to the local network, for example, ping to the IPV4 assigned to the windows host, and vice-versa.

You may already try this, but still, I'll leave what worked for me.

I'm using Ubuntu 20.04, and apt update is working fine.

Try to follow all the steps in order.

Edit the /etc/resolv.conf file with the following:

#/etc/resolv.conf
nameserver 8.8.8.8

To hold the file and avoid wsl to replace it every restart, edit the file /etc/wsl.conf:

#/etc/wsl.conf
[network]
generateResolvConf = false

Then in a windows command prompt execute this, before a new wsl session:

wsl --shutdown

Taken from this comment, and this other comment

@allexlima
Copy link

same problem here =(
I'm trying this -> https://support.microsoft.com/en-us/help/4577063/windows-10-update-kb4577063

Let me know if it worked...I nearly never update to preview builds but i might this time if it has the issue fixed.

After upgrade my Windows version, it worked fine. I hope it can work for you as well =)

@Lumenbolt
Copy link
Author

You can also check if the wsl is connected to the local network, for example, ping to the IPV4 assigned to the windows host, and vice-versa.

You may already try this, but still, I'll leave what worked for me.

I'm using Ubuntu 20.04, and apt update is working fine.

Try to follow all the steps in order.

Edit the /etc/resolv.conf file with the following:

#/etc/resolv.conf
nameserver 8.8.8.8

To hold the file and avoid wsl to replace it every restart, edit the file /etc/wsl.conf:

#/etc/wsl.conf
[network]
generateResolvConf = false

Then in a windows command prompt execute this, before a new wsl session:

wsl --shutdown

Taken from this comment, and this other comment

Tried this once again
& no luck :(
image

@Lumenbolt
Copy link
Author

same problem here =(
I'm trying this -> https://support.microsoft.com/en-us/help/4577063/windows-10-update-kb4577063

Let me know if it worked...I nearly never update to preview builds but i might this time if it has the issue fixed.

After upgrade my Windows version, it worked fine. I hope it can work for you as well =)

Strange..i did update to the preview build and no luck :(

@Lumenbolt
Copy link
Author

Please collect WSL logs and post the backlink to the feedback item here. Also please identify any third-party networking software that has been installed on Windows.

Here: https://aka.ms/AA9v0ml
I couldn't add any attachments since I've tinkered and debloated my PC, & disabled Diagnostics.
I don't have any third-party networking software installed.

@zhangshengsheng
Copy link

same problem

@zergvszerg
Copy link

same problem here.
I've tried to ping from wsl2 to windows host and from windows host to wsl2, and failed both times.

@piouson
Copy link

piouson commented Oct 12, 2020

been pulling my hair out on this one..

  • ping works from wsl, local 192.168.41.241 and remote 8.8.8.8, etc nameservers
  • dns works from wsl
  • Windows v1909 build 18363
  • Ubuntu 20.04.1 LTS
# ipconfig
Ethernet adapter vEthernet (WSL):
   IPv4 Address. . . . . . . . . . . : 192.168.41.241
   Subnet Mask . . . . . . . . . . . : 255.255.255.240
# cat /etc/resolv.conf
nameserver 192.168.41.241
# ip route
default via 192.168.41.241 dev eth0
192.168.41.240/28 dev eth0 proto kernel scope link src 192.168.41.252
# sudo apt update
Err:1 https://packages.microsoft.com/repos/azure-cli focal InRelease
  Could not connect to packages.microsoft.com:443 (13.80.99.124), connection timed out
Err:2 http://archive.ubuntu.com/ubuntu focal InRelease
  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable)
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable)
Err:5 http://security.ubuntu.com/ubuntu focal-security InRelease
  Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out

Workaround:
downgrade to wsl 1

# pwsh/cmd
wsl --set-version Ubuntu 1

@Nevrmnd
Copy link

Nevrmnd commented Oct 18, 2020

Had same issue and tried every solution I found, including the resolv.conf one, and nothing worked until I tried this:
#4731 (comment)

Now it works perfectly. Maybe there should be a way for Windows check for that folder during WSL 2 install if it is absolutely necessary for connectivity.

@Lumenbolt
Copy link
Author

Lumenbolt commented Oct 20, 2020

Had same issue and tried every solution I found, including the resolv.conf one, and nothing worked until I tried this:
#4731 (comment)

Now it works perfectly. Maybe there should be a way for Windows check for that folder during WSL 2 install if it is absolutely necessary for connectivity.

THIS WORKED!! FINALLY I'VE BEEN TRYING TO MAKE THIS WORK FOR ALMOST A MONTH!!
BOY if there was a way i could give you a million dollars!!

This worked for me:

  • Uninstalled all distro(s)
  • Created Temp folder in C:\Users[username]\AppData\Local (I created the folder for all the users in my pc, just in case)
  • Reinstalled Ubuntu from Microsoft store
  • Voila, sudo apt update worked right out of the box! Didn't have do any of the resolv.conf editing at all, the fresh new install of ubuntu connected to the internet with no issues!

@stidiovip
Copy link

It's important to end current sessions with this commande

wsl --shutdown

@Thribs
Copy link

Thribs commented Oct 29, 2021

It's important to end current sessions with this commande

wsl --shutdown

This did the trick for me. Thank you

@Kratorator
Copy link

For me, it was the firewall, my bad. Long before I started using WSL, I thought I was being smart when I changed the public profile inbound connections rule from "Block (default)" to "Block all connections". After all, that computer never leaves my home and is always set to private profile. I changed the public profile rule back to the default, and "sudo apt update" etc. worked immediately.

Why on earth are they using the public profile for WSL?

@Anamon
Copy link

Anamon commented Jun 3, 2024

Then in a windows command prompt execute this, before a new wsl session:

wsl --shutdown

Your solution worked for me, but only if I do not shutdown WSL. The fixed settings work immediately after saving the fixed resolv.conf file, but will be lost if shutting down WSL. If generateResolvConf is true, it will overwrite it with the wrong nameserver once WSL boots up again. If generateResolvConf is false, it will simply delete the resolv.conf file, regardless of its contents, so DNS resolution still doesn't work.

I think the correct way to keep WSL from breaking DNS resolution on every boot, is to make the fixed resolv.conf file read-only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

13 participants