12

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 gitosis@test.com: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.

Braiam
  • 1
  • 11
  • 47
  • 78
firedev
  • 20,898
  • 20
  • 64
  • 94
  • 2
    If you can ping, try using the IP address. `git clone gitosis@174.36.85.72:test.git`. I'd also take a look at `nslookup test.com` to ensure it resolves correctly. – Steven V Feb 25 '13 at 01:07
  • Of course I could use IP address but I want to fix it once and for all. And most important - to understand what is causing it. – firedev Feb 25 '13 at 03:30

6 Answers6

25

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
chirinosky
  • 4,438
  • 1
  • 28
  • 39
  • Who could've thought! after using nslookup I saw there is some recursion going on: `;; Got recursion not available from 203.144.206.49, trying next server`, changing to Google DNS fixed it. Thanks! – firedev Feb 25 '13 at 03:41
  • Haha, it happens sometimes, especially when one thing seems to work. Glad you got it working! – chirinosky Feb 25 '13 at 05:21
  • In my case, I've added the blow lines to /etc/resolv.conf: nameserver 8.8.8.8 nameserver 8.8.4.4 – Nobu Apr 22 '13 at 20:24
2

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.

Ozesh
  • 6,536
  • 1
  • 25
  • 23
1

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

localmachine $ git pull ssh://someusername@127.0.0.1:38765
ssh: Could not resolve hostname : No address associated with hostname
fatal: The remote end hung up unexpectedly

localmachine $ git pull ssh://someusername@127.0.0.1:38765/
someusername@127.0.0.1's password:

That error message is just misleading.

kungfooman
  • 4,473
  • 1
  • 44
  • 33
0

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
f.kowal
  • 149
  • 2
0

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.

thinwa
  • 295
  • 3
  • 9
-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
Pang
  • 9,564
  • 146
  • 81
  • 122