question

PMM-0934 avatar image
1 Vote"
PMM-0934 asked JacobWood-5741 published

WSL 2: "sudo apt-get update" gives "Temporary failure resolving ..." error

Installed WSL 2 (Debian, but previously tried Ubuntu with same issues). Installation went smoothly, but when I tried the following:

wsl2-prompt> sudo apt-get update

I get the following output to the terminal:

Err:1 http://security.debian.org/debian-security bullseye-security InRelease
Temporary failure resolving 'security.debian.org'
Err:2 http://deb.debian.org/debian bullseye InRelease
Temporary failure resolving 'deb.debian.org'
Err:3 http://ftp.debian.org/debian bullseye-backports InRelease
Temporary failure resolving 'ftp.debian.org'
Err:4 http://deb.debian.org/debian bullseye-updates InRelease
Temporary failure resolving 'deb.debian.org'
Reading package lists... Done
W: Failed to fetch http://deb.debian.org/debian/dists/bullseye/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/bullseye-updates/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/bullseye-security/InRelease Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://ftp.debian.org/debian/dists/bullseye-backports/InRelease Temporary failure resolving 'ftp.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.

I am aware that there are networking issues with WSL 2 and have spent 4 days trying to sort out my issues. Unfortunately, there are many "try this, try that" suggestions out there with no clear answer (and certainly no clear reason for why there is this problem to begin with). Many of the suggestions actually contradict each other, which is not helpful (e.g., "change /etc/wsl.conf to have 'generateResolvConf=false' versus just putting 'generateResolvConf' per the docs.microsoft.com troubleshooting guides)

I do have Cisco AnyConnect but the problem I am experiencing (see above) occurs independent of whether VPN is working or not, so the underlying issue does not seem to be related to the "Cisco AnyConnect" problem for which I have also seen suggestions posted.

For the record, I have successfully installed WSL1 and have full "apt-get upgrade" capability. The problem is inherent with WSL2.

I have tried a hundred different combinations of things, like changing the contents of /etc/resolv.conf, /etc/wsl.conf, ~/.wslconfig, etc as suggested by several resources including including https://docs.microsoft.com/en-us/windows/wsl/troubleshooting, https://gist.github.com/coltenkrauter/608cfe02319ce60facd76373249b8ca6, https://janovesk.com/wsl/2022/01/21/wsl2-and-vpn-routing.html

Summary: what do I need to do, step-by-step, to get "sudo apt-get update" to work without a "Temporary failure resolving ..." error in my WSL2/Debian installation?

windows-10-network
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have a similar problem but I have no VPN. What I do have is Oracle VirtualBox installed, and the VIrtualBox software sets up its own virtual ethernet adapter with nameservers specified like this:

DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1

Somehow when you convert a WSL2 distribution (like Ubuntu-20.04 or Debian) to WSL2, the Hyper-V Virtual Ethernet Adapter set up by WSL2 gets these VirtualBox nameservrers instead of the one my REAL ethernet adapter has, which is just 10.0.0.1, the address of the router behind which my PC is located. The router attaches to a cable modem from the cable company who supplies my internet access.

I tried the resolv.conf and wsl.conf solution, using 10.0.0.1 for the resolv.conf nameserver value, but it did not help - still could not use sudo apt update and had to revert the instance back to WSL1.

If anyone else solves this non-VPN problem I would appreciate hearing about it. p j farley 3 at yahoo dot com will reach me privately if you prefer.

Peter

0 Votes 0 ·
LimitlessTechnology-2700 avatar image
4 Votes"
LimitlessTechnology-2700 answered JacobWood-5741 published

Hi @PMM-0934

This error can happen when fetching the latest repositories during " apt-get update " was interrupted, and a subsequent " apt-get update " is not able to resume the interrupted fetch. In this case, remove the content in /var/lib/apt/lists before retrying " apt-get update ".

For many users, this problem seems to be related to VPN. Check if starting WSL-Ubuntu and then connecting the VPN is resolving your problem if you are using any VPN on your PC.

Try this Powershell command wsl --shutdown And then restart wsl and see if this sorts the issue. Even though it is a simple restart this has helped a lot of users.

Hope this resolves your Query!!


--If the reply is helpful, please Upvote and Accept it as an answer–

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you!

wsl --shutdown resolved this for me. Windows 11 beta, WSL2, Kali and Ubuntu.

2 Votes 2 ·
mustafaismaileyi-0409 avatar image
0 Votes"
mustafaismaileyi-0409 answered

Hello, @LimitlessTechnology-2700

I haven't used the wsl for a while like 7 month on my old laptop. Then, suddenly I faced the problem above. As you suggested write the "wsl --shutdown" on powershell and restart the wsl then it worked properly.

Thank you for your help!
Have a nice day.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.