I'm trying to SSH to an Eee PC laptop running Debian on a network where hostnames are automatically registered with DNS via the DHCP server. The Eee PC laptop had run out of power and gone to sleep and now when it's booted up again, the Mac can't see it except for the nslookup program.

gaz:~ jeff$ ssh epc
ssh: Could not resolve hostname epc: nodename nor servname provided, or not known
gaz:~ jeff$ nslookup epc

Name:   epc.osnetwork

gaz:~ jeff$ ssh epc.osnetwork
ssh: Could not resolve hostname epc.osnetwork: nodename nor servname provided, or not known

Now, ssh epc is how I normally access the Eee PC, but for some reason I think some part of OS X is caching a no-response despite the machine being online but I don't know how. I'm not even sure how to resolve this with any degree of certainty, I suspect a reboot will do it but for lack of a no-downtime solution I've just been using the IP address instead (which can still be obtained on the mac with nslookup epc, which is the most baffling part).

If I SSH to another Mac that didn't try to contact the Eee PC while it was down, that Mac can SSH to it without problems, but when I go back to the original Mac it still can't reach the hostname.

Other non-Apple machines on the network do not appear to suffer from this behavior.

Does anyone know why this is happening, or have ideas on how to fix this behavior?

[EDIT] I've found that coming back a half hour later to try again worked, but I'd still like to know why this is happening and how to correct it.


You've encountered the overly zealous OS X DNS Cache. Next time you see this you can flush it:

# sudo dscacheutil -flushcache

That should fix SSH, etc.

  • Actually, it seems I spoke too soon. After running that command, I wasn't able to ssh to any of the machines on my local network. Most peculiar. Waiting it out allowed me to eventually ssh to said machines again. Thanks for the tip though :) – Jeff Welling Sep 12 '11 at 21:02
  • It seems to work some of the time, and at other times prevents me from ssh-ing to any of the hostnames on my network. Ah well, focusing on the positive.. – Jeff Welling Oct 3 '11 at 11:45
  • We used to use that command reliably in Snow Leopard, however a couple of our devs updated to Lion and it gives unreliable results for flushing now. Although we don't run into the issue where no hostnames work, that sounds like a broken DNS server somewhere. – polynomial Oct 3 '11 at 14:42
  • 1
    For instructions on flushing the DNS cache in newer versions of OS X: support.apple.com/en-us/HT202516 – KQS Mar 20 '15 at 17:26

The command in Mavericks and Yosemite (starting from 10.4) is:

sudo killall -HUP mDNSResponder

Source: https://support.apple.com/en-us/HT202516

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.