Skip to content

Instantly share code, notes, and snippets.

@tkaczenko
Last active March 25, 2024 14:25
Show Gist options
  • Save tkaczenko/79c6dc1c8c87d0acc47d91495568cc17 to your computer and use it in GitHub Desktop.
Save tkaczenko/79c6dc1c8c87d0acc47d91495568cc17 to your computer and use it in GitHub Desktop.
WSL2: Temporary Failure in Name Resolution

WSL2: Temporary Failure in Name Resolution

Source

Instructions

In WSL2, run:

# remove existing resolv.conf symlink that is pointing to a wrong nameserver
sudo rm /etc/resolv.conf
# create a new resolv.conf with a correct nameserver or nameservers if you're using VPN
sudo bash -c 'echo "nameserver 1.1.1.1" > /etc/resolv.conf'
# stop wsl from regenerating resolv.conf symlink
sudo bash -c 'printf "[network]\ngenerateResolvConf = false" > /etc/wsl.conf'
# make current resolv.conf immutable so that wsl does not delete it
sudo chattr +i /etc/resolv.conf

In powershell, run:

wsl --shutdown
wsl

DNS servers

any additional DNS servers if you're using VPN
nameserver 1.1.1.1 # cloudflare
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment