I've experimenting with configuring dnsmasq on macOS for Apache vhosts instead of creating entries in /etc/resolver/<domain> for each domain. In my case, I configured dnsmasq to resolve .dev to localhost.

Since Safari had previously visited foo.dev, it kept requesting that page, although dig resolved foo.dev to localhost.

It didn't help to clear Safari's web cache and flush the system's DNS cache:

sudo dscacheutil -flushcache

It was first after a reboot that Safari properly visited the localhost instance of foo.dev (vhost).

So, is Safari mantaining its own DNS cache - and if so, how can it be flushed without restarting the system?

1 Answer 1

  1. To clean DNS cache on macOS, the following command should be used. (commands used to clean caches seems to be different on different version of macOS)

    sudo killall -HUP mDNSResponder
  2. Clean the DNS cache in Safari. Open Safari, Preferences -> Advanced. Check "Show develop menu in menu bar". Then go to menu bar, Develop -> Empty Caches. The shortcut is ⌥⌘E. (Restart of Safari may be needed)


  • 1
    thank you. Can you explain why sudo killall -HUP mDNSResponder works, and where it's documented?
    – Shuzheng
    Commented Sep 11, 2019 at 18:21
  • 1
    @Shuzheng apple.stackexchange.com/a/303119/269354
    – Simba
    Commented Sep 11, 2019 at 18:33
  • Any way without restarting anything including the browser?
    – Jonny
    Commented Feb 25, 2022 at 1:49

You must log in to answer this question.

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