$ sudo apt-get update Err:1 http://archive.ubuntu.com/ubuntu focal InRelease Temporary failure in name rerolution $ host google.com ;; connection timed out; no servers could be reached
The /etc/resolv.conf is the main configuration file for the DNS name resolver library. It was automatically generated by WSL. Some time there was a problem with that DNS.
- To stop automatic generation of resolv.conf, add the following entry to /etc/wsl.conf:
$ sudo cat << EOF > /etc/wsl.conf [network] generateResolvConf = false EOF
- In a cmd/powershell window, run:
> wsl --shutdown
> wsl --terminate <Distro>
- Restart WSL
- Create a file: /etc/resolv.conf. If it exists (even a link), replace existing one with new file.
sudo cat << EOF > /etc/resolv.conf # Use one or many DNS servers you like # nameserver 192.168.1.1 nameserver 220.127.116.11 nameserver 18.104.22.168 EOF
- Shutdown and restart WSL again.
Still not working
cmd/powershell as admin:
> wsl --shutdown > netsh winsock reset > netsh int ip reset all > netsh winhttp reset proxy > ipconfig /flushdns
- Colten Krauter: Fix DNS resolution in WSL2
- RedHat: Chapter 27. Manually configuring the /etc/resolv.conf file
- StackExchange: How do I set my DNS when resolv.conf is being overwritten?
- TechMint: How To Set Permanent DNS Nameservers in Ubuntu and Debian
- rescenic: No network connection in any distribution under WSL 2