After upgrading from WSL to WSL2
sudo apt-get update
not works any longer. After:
wsl --set-version Ubuntu-18.04 2
Output is:
> sudo apt-get update
Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
After going back to WSL1 the problem disappears again. Same on Debian and analogous in CentOS .. so WSL2 must have a bug.
The Windows10 build Version is 19041 and was installed today.
Any work around for WSL2? Regards
WSL supports a variety of Linux distributions, including the latest Ubuntu release, Ubuntu 20.04 LTS and Ubuntu 18.04 LTS.
WLinux is a custom Linux distro built from Debian specifically for use on the WSL. While other distros are available for WSL, WLinux is the first optimized for use by users of WSL for WSL. It helps developer run Linux tooling on Windows and integrates into perfectly into Windows.
As of March 2018 Debian is available for Windows users through the Windows store as an app for the Windows Subsystem for Linux (WSL). The app gives you a Debian stable command line environment running on the Windows kernel (WSL1) or Hyper-V with the new WSL2 interface depending on your Windows 10 release version.
The generated file /etc/resolv.conf is:
nameserver 172.24.0.1
..had to change it to
nameserver 8.8.8.8
which resolves the problem
In my case I was using a VPN in Windows, when disconnecting from the VPN the problem was resolved.
However, this is becoming a wider issue, it's happened again to me and I've solved it by removing Hyper-V Virtual Switch Extension Adapter.
The two solutions most widely used at the moment for this issue are:
/etc/wsl.conf
.[network]
generateResolvConf = false
cmd
window, run wsl --shutdown
/etc/resolv.conf
. If it exists, replace existing one with this new file.nameserver 8.8.8.8
git
working fine now.Credits to NonStatic who shared it on github
First go to device manager
Show hidden devices
Delete all Hyper-V Virtual Switch Extension Adapter
Credits to Jaysonsantos who shared it on GitHub
I was experiencing the same issue.
Do cat /etc/resolv.conf
, and see if the output has something like this:
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.X.X.X
You'll need to change the nameserver to 8.8.8.8
, so run sudo nano /etc/resolv.conf
, edit and save the file.
However, this is more or less a temporary solution, as you'll need to do this every time WSL starts. You might wanna run a script that checks the nameserver and updates it to 8.8.8.8 every time you reboot wsl. This change does work for my WSL2-Debian. But I don't need to restart the WSL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With