How to troubleshoot DNS issues on macOS
Updated 2022-04-08 · Published 2018-01-28

Below are a few methods and tools to help troubleshoot DNS on a Mac. This includes displaying the current DNS configuration, clearing your DNS cache, how to query a DNS server, and to even view the current DNS cache.
Display DNS configuration
To display your DNS configuration, run the following command from a terminal.
scutil --dns
Clear DNS cache
Sometimes you need to clear you DNS cache. In order to do this, run the following commands from a terminal. Depending on your browser, you may need to also close your browser and clear it's own cache.
sudo killall -HUP mDNSResponder
sudo dscacheutil -flushcache
Query DNS with nslookup
If you need to do simple lookups you can use nslookup to query a DNS server for a response.
# query default DNS server
nslookup saucepan.org
# query Google's Public DNS Server
nslookup
server 8.8.8.8
saucepan.org
Query DNS with dig
If you need a more advanced view or need to trace the steps of DNS query, the dig tool is very useful.
# query all results
dig saucepan.org ANY
# query A records
dig saucepan.org A
# query MX records
dig saucepan.org MX
# query NS records
dig saucepan.org NS
# query using a specific nameserver
dig @ns-166.awsdns-20.com saucepan.org
# trace the path taken of a query
dig saucepan.org +trace
View DNS cache
Open Console, select your local machine, and search for mDNSResponder. Then open a terminal and type the command below. This will dump the current DNS cache into the console window.
sudo killall -INFO mDNSResponder