firedev
firedev

Reputation: 21088

Could not resolve hostname, ping works

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.

Upvotes: 13

Views: 51896

Answers (6)

thinwa
thinwa

Reputation: 385

Maybe this is a rare case, but in case your target server works on a non-standard port rather than 22 like mine, you need specify port like below:

ssh user@remote_server -p 2222

The port number should be passed to the command via -p argument. The error "could not resolve hostname" ocurred when I tryied to connect in this way: ssh user@remote_server:2222.

Upvotes: 0

Daniel Kishore
Daniel Kishore

Reputation: 1

This may be an issue with the proxy. Kindly unset and try.

git config --global --unset http.proxy
git config --global --unset https.proxy

Upvotes: -1

Ozesh
Ozesh

Reputation: 6964

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.

Upvotes: 2

f.kowal
f.kowal

Reputation: 159

if you've a network-manager installed

check /etc/nsswitch.conf

if you've got a line

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

remove the **[NOTFOUND=return]**

restart /etc/init.d/networking

the [NOTFOUND=return] prevents futher lookups if the first nameservwe doesn't respond correctly

Upvotes: 0

kungfooman
kungfooman

Reputation: 4893

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.

Upvotes: 1

chirinosky
chirinosky

Reputation: 4538

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

Upvotes: 25

Related Questions