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 learn.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://learn.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?

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

Hi @PMM

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–

I had the same issue after installing WireGuard on Ubuntu. Then I commented out this line in my wg0.conf file:

# DNS = 8.8.8.8

and restarted the service. The issue solved.

IF anyone is still stuck, this might be helpful. Found that the issue is due to the WSL is not getting DNS routed somehow.

How to fix

Run sudo nano /etc/resolv. conf to change the target DNS server

In nano overwrite the listed IP to your preferred DNS e.g. local DNS server, internet gateway/router or public DNS. I used these
nameserver 8.8.4.4

nameserver 8.8.8.8

Save and exit

Run sudo apt-get update again. It will work like charm

Hello, @Limitless Technology

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.