How to flush the DNS cache of Safari on macOS Mojave without restarting the system?

  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)

References

  • Flush cache of DNS on macOS Sierra & High Sierra