Could not resolve hostname, ping works
Asked Answered
C

6

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 [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.

Cotton answered 25/2, 2013 at 0:53 Comment(2)
If you can ping, try using the IP address. git clone [email protected]:test.git. I'd also take a look at nslookup test.com to ensure it resolves correctly.Rafaelarafaelia
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.Cotton
C
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
Colliery answered 25/2, 2013 at 1:17 Comment(3)
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!Cotton
Haha, it happens sometimes, especially when one thing seems to work. Glad you got it working!Colliery
In my case, I've added the blow lines to /etc/resolv.conf: nameserver 8.8.8.8 nameserver 8.8.4.4Macro
M
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.

Melmon answered 29/9, 2016 at 4:36 Comment(0)
T
1

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.

Thyroiditis answered 23/4, 2014 at 17:6 Comment(0)
F
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
Fingerling answered 10/7, 2013 at 10:1 Comment(0)
R
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.

Ritchey answered 6/4, 2023 at 4:3 Comment(0)
J
-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
Jaimiejain answered 29/6, 2017 at 4:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.