How Do You Solve a “No such host is known” Problem with Git Commands?

Problem scenario
You are running an SSH git command (to interact with GitLab, GitHub or some Git repository), but you get "No such host is known" message. What should you do to troubleshoot this problem?

Possible Solution #1
Use "git clone" (instead of "ssh"; you need to use the git command first).

Possible Solution #2
Try to ping If that fails, you may want to proceed with troubleshooting that (e.g., a DNS connection problem, ICMP packets could be blocked, or there is a firewall rule preventing resolution to this server). If the ping works, retype the original git command carefully.

Possible Solution #3
Verify the /etc/hosts file is working correctly. You may want to look at the /etc/resolv.conf file to see if it has an entry for a valid DNS server (such as, a common one).

Solution adapted from these postings:

Possible Solution #4
On a non-Windows system, you could do this to get more information:

GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone ssh://

(This was adapted from this website.)

Leave a comment

Your email address will not be published. Required fields are marked *