Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git - Could not resolve hostname

Tags:

git

I am in a private network using VPN and using Windows platform. I am trying to clone a git project using

git clone ssh://git@domain-name:somestring/str-somestring.git

But I getting ssh: Could not resolve hostname domain-name: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I having ssh generated in my local which I added to my local repo as well. Can someone help me out here?

I am sure I all the access for this project.

Update

ping google.com is working outside VPN, same is not working inside VPN

like image 396
Suganthan Madhavan Pillai Avatar asked Oct 28 '25 09:10

Suganthan Madhavan Pillai


1 Answers

The error message is quite clear. git cannot resolve domain-name.

Try, in the same shell you are typing your git commands:

ping domain-name
nslookup domain-name

They won't work either, 99% guaranteed.

If so, the easiest fix is to add that name and its IP address to /etc/hosts (as usual, nothing git related). When ping / nslookup work, git will as well.

EDIT to sum up the comments: The suggestion to modify /etc/hosts is primarily for debugging purposes - to directly rule out mysterious DNS issues not related to git. It would be much better to fix the actual issue (hard to give real advice about that, as there can be a great many root causes...). Tangentially, a popular problem on MacOS seems to be DNS caching - there are many resources online about this if one searches for "flush dns cache macos".

like image 52
AnoE Avatar answered Oct 30 '25 01:10

AnoE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!