Temporary Failure in name resolution on WSL
Solution 1
Inside WSL2, create or append file: /etc/wsl.conf
Put the following lines in the file in order to ensure the your DNS changes do not get blown away
sudo tee /etc/wsl.conf << EOF [network] generateResolvConf = false EOF
In a
cmd
window (!!), runwsl --shutdown
Start WSL2
Run the following inside WSL2
sudo rm -rf /etc/resolv.conf sudo tee /etc/resolv.conf << EOF search yourbase.domain.local nameserver 8.8.8.8 nameserver 1.1.1.1 EOF
Solution 2
I have the same problem. It also seems to be realted to VPN. I found out, that it only fails the DNS lookup when I first connect the VPN before starting WSL-Ubuntu after System-Reboot. First starting WSL-Ubuntu and afterwards connecting the VPN seems to work.
Solution 3
I had the same error. Pinging IP addresses worked, but no DNS resolution. Outside of WSL everything was fine. The problem was caused by OpenVPN for me, when I disconnected from my workplace's VPN, the error was gone.
Solution 4
For me it was a simple fix. From powershell:
wsl --shutdown
And then restart wsl
and it worked. Yes, I know this solution is too simple and might not be good to you if trying to avoid reset to WSL. But in case you look for something simple, maybe worth trying
Solution 5
When I ran ls -lah /etc/resolv.conf
, I saw that it was a symlink to ../run/resolvconf/resolv.conf
.
But then I noticed that ../run/resolvconf/resolv.conf
didn't exist, and in fact, although the /run/
directory existed, /run/resolvconf/
did not.
So I created that directory and also created an empty file sudo vim /run/resolvconf/resolv.conf
.
Then I edited that file to contain:
nameserver 1.1.1.1
After saving that file, ping google.com
worked!
(It seems like that file is required. I don't know how mine got removed.)
https://github.com/microsoft/WSL/issues/6601 was helpful for me.
m_bash
Updated on September 18, 2022Comments
-
m_bash over 1 year
Running Ubuntu on WSL and trying to push to github and download new python modules using pip and I get this error.
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f9d654fe0b8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/tensorflow/
I had a look at the resolv.conf file and maybe its corrupted as it just gives a few lines of @@@. Anyone got any ideas how to fix this?
When I run l
ls -al /etc/resolv.conf -rw-r--r-- 1 root root 261 Nov 28 12:54 /etc/resolv.conf
Update:
I managed to fix the problem. Needed to edit the file and add a line like this:
nameserver 8.8.8.8
-
Terrance over 4 yearsIt might be corrupted. When looking at what is contained in the
/etc/resolv.conf
it is actually a link to/run/resolvconf/resolv.conf
The file is supposed to be automatically generated by WSL. Maybe you need to recreate the/run/resolvconf/resolv.conf
file with just the line of# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.
-
Boris Hamanov over 4 yearsEdit your question and show me
ls -al /etc/resolv.conf
. -
m_bash over 4 yearsI have edited the post
-
Boris Hamanov over 4 yearsThe symbolic link for /etc/resolv.conf is missing, and the static file contains garbage. So... temporarily edit /etc/resolv.conf (
sudo -H gedit /etc/resolv.conf
), remove everything there, and just enter8.8.8.8
and save the file. Retest. Report back. Start comments to me with @heynnema or I may miss them. -
m_bash over 4 years@heynnema Tried that and still no change.
-
Boris Hamanov over 4 yearsI'm not familiar with WSL, but if the /etc/resolv.conf file still contains 8.8.8.8, instead of garbage, something is really wrong. Because of the WSL component, I really can't suggest what to do next.
-
m_bash over 4 years@heynnema I fixed it. I just needed to add nameserver before the 8.8.8.8 and then it works fine. Thanks a lot
-
Boris Hamanov over 4 yearsThanks for the update! Glad it's working for you now.
-
-
Vaal almost 4 yearsThanks, that was it for me! Turns out it is triggered by the 'block-outside-dns' flag in my config. Used to work fine, but no longer after updating to 2004!.
-
David almost 3 yearsThat doesn't work for me
-
Guilherme almost 3 yearsIt is happened to me even without connecting the VPN
-
userfuser over 2 yearsThanks for mentioning the VPN! When I disabled my VPN (under Windows), the apt update in WSL started working.
-
Lucho about 2 yearsIt works. Wow. Nice!.
-
Admin almost 2 yearsI had to remove the brackets from the "search" line!
-
Admin almost 2 years@FrankPuck sorry my bad, i have fixed it
-
Admin almost 2 yearsThe sledgehammer worked for me, thanks @ferdinand-prantl. I have Sophos on top of windows firewall, so adding the rules for windows firewall did not seem to have any effects. With the sledgehammer, everything worked.