WSL: WSL2 cannot connect to the internet after upgrading from WSL1 (TRIED EVERYTHING!)

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 https://github.com/microsoft/WSL/issues/5256#issuecomment-666545999)

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 https://github.com/microsoft/WSL/issues/5256#issuecomment-667751572)

–> 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! 😃

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 17

Most upvoted comments

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

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!

Had same issue and tried every solution I found, including the resolv.conf one, and nothing worked until I tried this: https://github.com/microsoft/WSL/issues/4731#issuecomment-701134259

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.

It’s important to end current sessions with this commande

wsl --shutdown