DNS
DNS not resolving on a Mac
When DNS fails, the Mac cannot change a name such as apple.com into an IP address. The connection can work, but every site by name fails.
Symptoms
- Browsers show “server can't be found” or a similar error for many sites.
- Terminal tools show “Could not resolve host” or “nodename nor servname provided”.
- Apps that use IP addresses still work, but names do not.
- The problem starts after you change networks, connect a VPN or set custom DNS servers.
Likely causes
- No connection. The Mac has no working path to the internet, so DNS queries cannot go out.
- Wrong or unreachable DNS servers. A DNS server that you typed in by hand can stop working, or it can be blocked on this network.
- The router's DNS fails. Many networks send DNS to the router. If the router stops answering, names fail on every device.
- A VPN, profile or filter changes DNS. VPNs, encrypted DNS profiles and content filters can send queries to other servers.
- Old answers in the cache. The Mac keeps answers for some time. After a site moves, an old answer can fail.
How to check
Make sure that the connection works. Send pings to an IP address, so that DNS is not used.
ping -c 3 1.1.1.1Send pings to a name. If the IP address works and the name fails, DNS is the problem.
ping -c 3 apple.comAsk the macOS resolver for a name. This uses the same path as most apps.
dscacheutil -q host -a name apple.comOutput The
ip_addressandipv6_addresslines. No lines means that the lookup failed.Show the DNS configuration that macOS uses now. The first resolver is the default one.
scutil --dnsShow the DNS servers that you set by hand on the Wi-Fi service.
networksetup -getdnsservers Wi-FiOutput A list of IP addresses, or a message that there are no DNS servers set. Then the network gives the servers.
How to fix it
Remove DNS servers that you typed in by hand. Choose Apple menu > System Settings > Network.
Click the network service, click Details, then click DNS. Select each server that you added and click the Remove button.
You can also clear them in Terminal. Use the word
emptyin place of the server addresses.networksetup -setdnsservers Wi-Fi emptyNeeds an administrator password.
Clear the DNS cache. See Flush the DNS cache on a Mac.
sudo killall -HUP mDNSResponderNeeds an administrator password.
Get a new address and new DNS servers from the router. See Renew the DHCP lease on a Mac.
Disconnect the VPN for a test. If names then work, examine the VPN's DNS settings. See DNS queries go outside the VPN on a Mac.
If DNS fails on all devices, restart the router.
With Kilobat
Kilobat measures one DNS lookup and lists the resolvers in use. Look at
dnsMilliseconds,dnsServersandcaptivePortal.kilobat diagnose --jsonFor one site or API, find the layer that fails. It checks DNS before the connection.
kilobat why api.example.comThe CLI is free. In the app, the Health tab shows the DNS servers and the lookup time. See Find why one site or API won't connect.
Questions
Why does ping to 1.1.1.1 work but sites fail?
A ping to an IP address does not use DNS. If it works and names fail, the problem is DNS, not the connection.
Why does dig work when apps fail?
dig sends queries to the servers in /etc/resolv.conf. Apps use the macOS resolver, which can also use VPN and per-domain rules.
Will the router give me DNS servers again?
Yes. When the DNS list in Network settings is empty, macOS uses the servers that the network gives by DHCP.
Sources
- Apple Support: Change DNS settings on Mac
- Apple Support (archived): Reset the DNS cache in OS X
- scutil(8), man page installed with macOS 27.2
- dscacheutil(1), man page installed with macOS 27.2
- networksetup(8), man page installed with macOS 27.2
Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with man <name> in Terminal.