Menu & Search
Git Clone “Could not resolve hostname github.com”

Git Clone “Could not resolve hostname github.com”

An error message recieved within my VS Code WSL terminal when attempting to clone a new Git repository.

ssh: Could not resolve hostname github.com: Temporary failure in name resolution.
fatal: Could not read from remote repository.

A ping response brings back a name resolution error.

The reason for the error is because my WSL instance cannot connect to github.com. This isn’t something I needed to do in WSL Version 1.

The fix can be done in 2 ways:
# Create/Amend the /etc/wsl.conf File
# (Temp Fix) Amend the /etc/resolv.conf File


Create/Amend the /etc/wsl.conf File

dd


(Temp Fix) Amend the /etc/resolv.conf File

If not on WSL, this might be the actual fix.

Edit the /etc/resolv.conf file. I’m using Vim here.

sudo vim /etc/resolv.conf

Within vim, add 8.8.8.8 and 8.8.4.4 as nameserver addresses.

Now try ping github if successful the clone should work.

If unsuccessful look elsewhere & good luck 😉


Share

0 Comments