I'm trying to get my El Capitan's (10.11.6) DNS cache to flush, to try and solve slow localhost domain name resolution, but nothing I do has any effect. My computer name, hostname and hard disk names used to be as follows:

Santa's MacBook Pro
Santa's MacBook

(I didn't choose to put the "-2" at the end of the hostname; that's what the Mac had in the Sharing preference pane.)

I tried editing the etc/hosts file as follows:    localhost santas-macbook-pro-2.local    broadcasthost
::1             localhost santas-macbook-pro-2.local
fe80::1%lo0    localhost

but even after a restart the resolution was still as slow as ever.

Tried renaming the computer and hostname to trial and trial.local (updating etc/hosts accordingly) and the hard disk to tt. Got OnyX to flush various caches including system and kernel extensions, restarted, still slow.

In running the little inetTester I get Santa's MacBook Pro.local returned.

I've tried flushing the DNS cache following the instructions here, restarted, and I still get Santa's MacBook Pro.local returned.

It seems discoveryutil doesn't exist any more (in any case it's not on my machine), so I can't even look at the contents of the cache.

What on earth do I have to do to get this machine to forget about being Santa's MacBook Pro?

1 Answer 1


You are mixing a lot of completely or partly different/unrelated things here.

  1. To properly and quickly name resolve your hard disk/SSD, you also have to add its name to the hosts file:    localhost santas-macbook-pro-2.local tt-this_is_a_VM_volume_and_therefore_slower_than_a_real_disk 

    Now you can check the response time by pinging it:

    ping tt-this_is_a_VM_disk_and_therefore_slower_than_a_real_disk 
    PING tt-this_is_a_VM_disk_and_therefore_slower_than_a_real_disk ( 56 data bytes
    64 bytes from icmp_seq=0 ttl=64 time=0.054 ms
    64 bytes from icmp_seq=1 ttl=64 time=0.089 ms
    64 bytes from icmp_seq=2 ttl=64 time=0.071 ms
    --- tt-this_is_a_VM_disk_and_therefore_slower_than_a_real_disk ping statistics ---
    3 packets transmitted, 3 packets received, 0.0% packet loss
    round-trip min/avg/max/stddev = 0.054/0.071/0.089/0.014 ms

    The average round-trip time is ~0.071 ms. So the time needed to resolve it is less than ~0.071/2 ms. With a real HDD/SSD you can expect even faster responses.

    Please use the short tt (the name of your volume) instead of my long tt-this_.... name to get an even quicker response.

  2. To check your DNS cache open Console.app (enter mDNSResponder in the Search field) and Terminal.app.

    Check the time and enter in Terminal: sudo killall -INFO mDNSResponder

    Roughly the first half of the output in Console with the time stamp noted previously is the DNS cache. The cache part starts with ------------ Cache ------------- and ends with a summary like Cache currently contains 391 entities; 33 referenced by active questions.

    To kill the cache use sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

    Re-check the cache by entering sudo killall -INFO mDNSResponder again.

  3. discoveryutil was introduced in OS X 10.10.0 and replaced by its predecessor mDNSResponder in OS X 10.10.4.

  4. To modify your local hostname and computer name use scutil:

    sudo scutil --set LocalHostName trial
    sudo scutil --set ComputerName Trial

    If you still get a Bonjour name (e.g. Santa's MacBook Pro.local) your hostname is probably set incorrectly. Either change the hostname by entering:

    sudo scutil --set HostName trial

    or remove it completely (recommended) by modifying the file preferences.list:

    sudo  nano /Library/Preferences/SystemConfiguration/preferences.plist

    and remove your current malformed HostName near the bottom of the file:

        <string>Santa's MacBook Pro.local</string>


    You may also have to remove the preferences backup file preferences.plist.old. Reboot afterwards.

  5. Name resolution is roughly done in this order:

      files (e.g. /etc/hosts) > mDNS > DNS)  \
       ↕︎                         (↓ )   (↓)   | rather remote hostnames
    DNS cache (memory) (←-----------------)  /
       ↑                                       \
    memory                                      | rather local hostnames (including hosts file)
       ↑                                        |
     file (preferences.plist)                  /
  6. inetTester is a tool to quickly check the elapsed time spent from the Java layer to access the localhost domain name. This is not the time to get (resolve) the local hostname. The hostname is stored somewhere in memory and a system call takes nanoseconds to get it.

  7. The name of your main volume (previously Santa's MacBook, now tt) is in no way related with the DNS cache or a slow local hostname resolution.

Regarding item 1 in the list. I wear Dark Vader's helmet party hat and got nasty temporarily.

  • Thanks @klanomath. I realise the HD has nothing to do with DNS resolution but I'm getting desperate to solve this problem & wanted to make sure nothing about Santa's MacBook was left. I've done your step 2 & the cache has nothing about Santa in it. Good to know. scutil --get LocalHomeName and [...] ComputerName both give me trial so they are clearly set right. And still inetTester gives me back Santa's MacBook Pro.local!!! Having stepped through its source I realise the string is coming from somewhere in memory. The question is where, and how do I get rid of it?
    – skiaddict1
    Dec 21, 2016 at 2:18
  • Oops, scutil --get LocalHostName
    – skiaddict1
    Dec 21, 2016 at 2:19
  • Marked as correct answer since the cache is indeed, clearly, being flushed. However any help you could give me to get rid of Santa's MacBookPro.local would be greatly appreciated!!! :-)
    – skiaddict1
    Dec 21, 2016 at 2:42
  • Awesome. It was indeed Santa's[...] so I changed it to trial.local. inetTester now resolves in 77ms. Thank you so much for this, I'm now well on the way to solving the original problem which necessitated delving into DNS resolution. You may sometimes be a Darth, but you're definitely a force for good! ;-)
    – skiaddict1
    Dec 21, 2016 at 3:14
  • @skiaddict1 By definition trial.local as hostname is wrong. You should set it to trial! trial.local is the full local host name (Bonjour) which is built by the LocalHostName set by scutil (or in the Sharing Prefs) and the standard suffix .local. This is part of an RFC!
    – klanomath
    Dec 21, 2016 at 3:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .