Temporary Failure in name resolution on WSL

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

Solution 1:

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 2:

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 3:

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 4:

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.