Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not resolve hostname, ping works

Tags:

networking

I have installed RasPi Raspbian, and now I can't do ssh or git clone, only local host names are being resolved it seems. And yet ping works:

pi ~ $ ssh test.com
ssh: Could not resolve hostname test.com: Name or service not known

pi ~ $ git clone [email protected]:test.git
Cloning into 'test'...
ssh: Could not resolve hostname test.com: Name or service not known
fatal: The remote end hung up unexpectedly

pi ~ $ ping test.com
PING test.com (174.36.85.72) 56(84) bytes of data.

I sort of worked around it for github by using http://github.com instead of git://github.com, but this is not normal and I would like to pinpoint the problem.

Googling for similar issues but the solutions offered was either typo correction, or adding domains to hosts file.

like image 692
firedev Avatar asked Feb 25 '13 00:02

firedev


People also ask

Can ping but Cannot resolve hostname?

The reason ping can't resolve the hostname but nslookup can is because nslookup a low-level tool that bypasses the Windows DNS client. It uses whatever DNS server you tell it to (the first one by default), and does the query on the fly.

Why does ping work but not nslookup?

If nslookup works but ping fails, it's possible that the hosts' file was edited by malware or another application, and that can cause this and similar problems to appear. To fix the problem, it's advised to check this file and make sure that everything is in order.

What does it mean when it says cant resolve hostname?

This error means that the hostname you are trying to connect to cannot be resolved to an IP address. (Hostnames are resolved to IP addresses by a DNS (Domain NameServer)). Please check what you have entered in the Address field. You will need the valid hostname of an FTP server or a valid IP address.


3 Answers

This sounds like a DNS issue. Try switching to another DNS server and see if it works.

OpenDNS

  • 208.67.222.222
  • 208.67.220.220

GoogleDNS

  • 8.8.8.8
  • 8.8.4.4
like image 154
chirinosky Avatar answered Oct 23 '22 08:10

chirinosky


Try reseting te contents of the DNS client resolver cache. (For windows) Fireup a command prompt and type:

ipconfig /flushdns

If you are a linux or mac user, they have their own way of flushing the dns.

like image 25
Ozesh Avatar answered Oct 23 '22 08:10

Ozesh


Had the same error, I just needed to specify a folder:

localmachine $ git pull ssh://[email protected]:38765
ssh: Could not resolve hostname : No address associated with hostname
fatal: The remote end hung up unexpectedly

localmachine $ git pull ssh://[email protected]:38765/
[email protected]'s password:

That error message is just misleading.

like image 44
kungfooman Avatar answered Oct 23 '22 10:10

kungfooman