Slow DNS Lookup Causes and Fixes at a Glance
A slow DNS lookup is the wait before a connection starts, while a resolver turns a name such as example.com into an IP address.
| What you see | Likely cause | Go to |
|---|---|---|
| A repeatable pause close to a resolver timeout, often 5 s on Linux | An unresponsive configured DNS server | Dead first DNS server |
| First visit slow, repeat visits fast, on every site | Slow or distant resolver on cache misses | Choose a faster DNS resolver |
Lookups stall but dig A answers at once | AAAA queries dropped by a resolver or router | IPv6 and AAAA lookup delays |
| Only one domain is slow everywhere | A problem with that domain's authoritative DNS, delegation or DNSSEC | One domain or every domain |
| Slow only with a VPN connected | The VPN pushes its own DNS servers | Measure again with the VPN off |
| Browser slow while command line tests are fast | Browser secure DNS uses its own resolver | Check browser secure DNS |
| Every device on the network is slow | The DNS server the router hands out | Router or whole network |
The steps apply to Windows 10 and 11, Windows Server 2016 and later, current macOS releases, Linux distributions that use glibc, and home or office routers. You need administrator or root rights on the device you change.
The Linux timings below are real measurements. The platform-specific configuration steps are documented guidance, not tests performed for this guide.
The address 203.0.113.53 used in examples is a documentation address. The public resolvers named later are real, so check their current addresses on the providers' own pages before you use them.
Measure DNS Lookup Time Before Changing Anything
Measure DNS lookup time first, because a page can be slow for reasons that have nothing to do with DNS.
Time a Lookup With dig
Time a lookup with dig by sending the same query twice and reading the Query time line each time.
dig cold1250518534.wikipedia.org +noall +comments +statsReal output from Ubuntu 24.04.5, run twice in a row. The name was random, so it was unlikely to be cached before the test, and it does not exist, which is why the status is NXDOMAIN.
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 14963
;; Query time: 20 msec
;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 55230
;; Query time: 0 msec
;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)The first query was likely a cache miss and shows the work needed when the resolver has no cached answer. The second most likely came from the resolver cache. Resolvers cache "does not exist" answers too, which is why the second query was faster, so use a new name each time you test the cold path.
dig sends its query to the DNS server listed in /etc/resolv.conf. If that is a local caching stub such as 127.0.0.53, the stub can still serve a cached answer, so add @server to test an upstream resolver directly. dig does not use the hosts file or reproduce the full lookup path a browser uses. On Linux, getent ahosts example.com goes through the system name resolution path most programs use.
Time a Lookup on Windows
To time a lookup on Windows, open PowerShell as administrator, clear the client cache and wrap Resolve-DnsName in Measure-Command.
Clear-DnsClientCache
Measure-Command { Resolve-DnsName example.com -Type A -DnsOnly } | Select-Object TotalMillisecondsRun it three times. A first run in the hundreds of milliseconds with fast repeats points at the resolver. Every run taking seconds points at a timeout, covered further down. -Type A asks for IPv4 only. Run it again with -Type AAAA to time the IPv6 query on its own.
Time a Lookup on macOS
To time a lookup on macOS the way apps do, use dscacheutil, because dig skips the macOS resolver and any VPN scoped servers.
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
time dscacheutil -q host -a name example.com
scutil --dnsThe first line clears the cache, so the timed run is a cold lookup and later runs may come from cache. dscacheutil goes through the system lookup path that apps use. scutil --dns lists every resolver macOS knows, including ones a VPN added for certain domains. dig is also included on macOS for timing a single server.
Split DNS Time From the Rest of the Page Load
Split DNS time from the rest of the page load with curl, which prints each phase in seconds from the start of the request.
curl -s -o /dev/null -w 'dns %{time_namelookup} connect %{time_connect} tls %{time_appconnect} first byte %{time_starttransfer} total %{time_total}\n' https://example.com/If dns is a small part of total, DNS is not your problem, and the delay sits in the connection, TLS or the server. In a browser, the Timing tab of developer tools shows the same split as DNS Lookup. With an HTTP proxy set, for example through HTTPS_PROXY, curl only resolves the proxy name and the proxy resolves the site, so time_namelookup no longer measures the site lookup. Unset proxy variables for this test.
Check Browser Secure DNS
Browser secure DNS (DNS over HTTPS) can send lookups to its own resolver, so changing the system DNS server may not change the browser.
In Chrome, open Settings, Privacy and security, Security, then Use secure DNS. In Edge, open Settings, Privacy, search, and services, Security, then Use secure DNS. Note the current choice, turn it off for the test, restart the browser and compare. Put the original setting back after the test, since it may be there for privacy or company policy.
Find Out if One Domain or Every Domain Is Slow
Find out if one domain or every domain is slow, because that tells you whether to fix your side or the domain's nameservers.
| Scope | Side | What to check |
|---|---|---|
| Every domain, one device | That device | Its DNS server list, VPN, browser secure DNS setting |
| Every domain, every device | Router or resolver | DNS servers the router uses and hands out |
| One domain, every network | The domain's authoritative nameservers | Its NS records and how fast each one answers |
| IPv6 or AAAA lookups only | Resolver or router handling of AAAA | The AAAA test below |
For one slow domain, list its nameservers and ask each one directly. +norecurse asks only for what that server holds, so the time is that server alone.
dig NS example.com +short
dig @a.iana-servers.net example.com +norecurse +stats
dig example.com +traceReplace example.com with the slow domain. Then run the second command once for each nameserver the first command returns, in place of a.iana-servers.net, and compare the response time and answer from every nameserver. If one is consistently slow or silent, or the answers differ, use +trace to inspect the delegation path and any CNAME chain from the root down. It does not validate DNSSEC, so use a DNSSEC validation tool if you suspect a validation problem. Repeat from another network before you blame the server, then give the results to the domain owner or its DNS provider, the only ones who can fix it.
These three commands were not timed for this guide, because the test network sends all port 53 traffic through its own resolver, which would make the numbers meaningless.
A Dead First DNS Server Adds Seconds to Every Lookup
A dead first DNS server adds seconds to every lookup, because the resolver waits for it to time out before it asks the next one.
On Linux, glibc reads up to 3 servers from /etc/resolv.conf and tries them in order. Its default timeout is 5 seconds and it makes 2 attempts by default, per the resolv.conf manual page. Any cache in front of glibc, such as systemd-resolved, has its own rules.
What a Dead Resolver Costs in a Real Test
In a real test, a dead resolver costs one full timeout for each new name, even though every lookup still succeeds.
The dead resolver was a local listener at 127.0.0.77 that receives queries and never replies, placed first in front of a working server.
nameserver 127.0.0.77
nameserver 8.8.8.8time getent ahostsv4 example.org | head -1104.20.26.136 STREAM example.org
real 0m5.016s| Resolver setup | Tool | Time |
|---|---|---|
| Dead server first, defaults | getent ahostsv4 | 5.016 s |
Dead server first, options timeout:1 attempts:2 | getent ahostsv4 | 1.008 s |
| Working server first, dead server second | getent ahostsv4 | 0.013 s |
| Dead server first, defaults | nslookup | 30.055 s |
Nothing fails, which is what makes this fault hard to spot. nslookup took 30 seconds in the same setup because it uses its own retry and timeout behaviour, so its timing does not represent the lookup path most programs use.
Check Each Configured Server One by One
Check each configured server one by one with a short timeout, so a dead one shows up in 2 seconds instead of hanging.
dig @127.0.0.77 example.org +tries=1 +time=2;; communications error to 127.0.0.77#53: timed out
; <<>> DiG 9.18.39-0ubuntu0.24.04.9-Ubuntu <<>> @127.0.0.77 example.org +tries=1 +time=2
; (1 server found)
;; global options: +cmd
;; no servers could be reachedOn Windows, list the servers with Get-DnsClientServerAddress and test each with Resolve-DnsName example.com -Server 203.0.113.53 -DnsOnly, using your server addresses in place of the example. A server that times out should come out of the list.
Remove the Dead Server or Shorten the Wait
Remove the dead server from the list, which is the real fix, using the steps for your system below.
If you cannot remove it yet, options timeout:1 attempts:2 in /etc/resolv.conf cut the wait from 5 to 1 second in the test. It is a trade-off: on a link with high delay, a 1 second timeout can give up on a server that is slow but working. It also does not survive on systems where a network tool rewrites the file.
Test IPv6 and AAAA Lookup Delays
IPv6 and AAAA lookup delays happen when a resolver or router answers A queries but drops or stalls AAAA queries.
Programs that support IPv6 usually ask for an AAAA record (IPv6 address) and an A record (IPv4 address) together. Under RFC 8305, the client should fire off the AAAA query first and the A query right after it. If the A answer arrives first, the client waits up to about 50 ms for the AAAA answer. Programs that wait for both results through the system resolver can sit through full timeouts when the AAAA reply never comes.
Query A and AAAA Records Separately
Query A and AAAA records separately against the same server, so you can see which of the two is the slow one.
dig @127.0.0.78 example.org A +noall +stats +tries=1 +time=2 | grep 'Query time'
dig @127.0.0.78 example.org AAAA +tries=1 +time=2 2>&1 | grep -E 'timed out|reached';; Query time: 0 msec
;; communications error to 127.0.0.78#53: timed out
;; no servers could be reachedThe listener at 127.0.0.78 was a test resolver built to forward A queries and silently drop AAAA queries, the pattern some faulty routers and filters show. Against your own resolver, run the same two commands without the @ part. A healthy resolver answers both, with an empty answer section if a name has no IPv6 address.
What Dropped AAAA Queries Cost in a Real Test
Dropped AAAA queries cost 15 seconds per lookup in this test, measured with Python asking the system for both address types.
The test machine used this /etc/resolv.conf, with one options line added for each variant in the table.
nameserver 127.0.0.78time python3 -c 'import socket; print(len(socket.getaddrinfo("example.org", 443)))'| Resolver and options | Time |
|---|---|
| Drops AAAA, no options (timeout 5) | 15.048 s |
Drops AAAA, options attempts:1 | 15.080 s |
Drops AAAA, options timeout:2 | 6.043 s |
Drops AAAA, options timeout:1 attempts:2 | 3.052 s |
Drops AAAA, options single-request | 10.037 s |
| Healthy resolver at 8.8.8.8 | 0.090 s |
With glibc 2.39 the wait came to about three times the timeout value whether attempts was 1 or 2, so lowering attempts did not help here. That pattern comes from internal retry steps and can differ between glibc versions. single-request made it worse, because it does not help a resolver that drops AAAA outright.
Plain getent ahosts returned at once in the same setup, because the test machine had no IPv6 address and glibc skipped the AAAA query. On glibc 2.35 and later, --no-addrconfig turns that filter off so you can test both types through the system resolver.
time getent --no-addrconfig ahosts example.org | head -1172.66.157.237 STREAM example.org
real 0m15.017sThe same command against the healthy resolver took 0.005 s. A slow result here with a fast dig A points straight at AAAA handling.
Fix AAAA Delays Without Turning Off IPv6
Fix AAAA delays at the resolver first, because turning off IPv6 hides the fault and can break sites that need it.
- Point the device or router at a resolver that answers AAAA queries, using the steps below.
- Update the router firmware or turn off a DNS filter feature on it if the router is the resolver that drops them.
- Give the device working IPv6 DNS servers too, since a router can hand out a dead IPv6 DNS address while IPv4 DNS works.
- On Linux,
options single-requestsends the A and AAAA queries one after the other, for equipment that mishandles two queries sent in parallel.options single-request-reopeninstead closes the socket and opens a new one before sending the second query, for equipment that mishandles A and AAAA requests sent from the same socket. Both cost some speed and neither fixes a resolver that drops AAAA entirely, as the table shows.
Change the DNS Server on Windows
Change the DNS server on Windows with PowerShell as administrator, after saving the current settings so you can roll back.
- Find the adapter nameRun
Get-NetAdapterand note the Name of the connected adapter, for exampleEthernetorWi-Fi. - Save the current serversRun
Get-DnsClientServerAddress -InterfaceAlias 'Ethernet' | Format-List | Out-File $env:USERPROFILE\dns-before.txtso the old values are on disk. - Set the new serversUse the command below, with IPv4 and IPv6 addresses of the resolver you chose.
- Flush and verifyClear the cache, confirm the list and time a lookup again as in the measuring section.
Set-DnsClientServerAddress -InterfaceAlias 'Ethernet' -ServerAddresses ('1.1.1.1','1.0.0.1','2606:4700:4700::1111','2606:4700:4700::1001')
Clear-DnsClientCache
Get-DnsClientServerAddress -InterfaceAlias 'Ethernet'
Resolve-DnsName example.com -DnsOnlyThe new servers should appear for both the IPv4 and IPv6 address families, and Resolve-DnsName should return addresses quickly. Static servers set this way override the ones DHCP hands out on that adapter.
To roll back, check dns-before.txt. If the adapter used DHCP before, run Set-DnsClientServerAddress -InterfaceAlias 'Ethernet' -ResetServerAddresses. If it had static servers, set those exact addresses again with the same command you used above. In Windows 11 Settings, the same choice is under Network and internet, your connection, DNS server assignment.
Check Active Directory DNS and NRPT Rules
Active Directory DNS and NRPT rules matter on domain joined machines, which must use DNS servers that hold the domain records.
Get-DnsClientNrptPolicy
Resolve-DnsName _ldap._tcp.dc._msdcs.corp.example.com -Type SRV -DnsOnlyReplace corp.example.com with your domain. If the SRV lookup fails after a change, the machine can no longer find its domain controllers. Name Resolution Policy Table rules, often set by a VPN or group policy, send some names to other servers whatever the adapter says.
Change the DNS Server on macOS
Change the DNS server on macOS in System Settings or with networksetup, after you note the servers in use now.
scutil --dns | grep 'nameserver'
networksetup -getdnsservers Wi-Fi
sudo networksetup -setdnsservers Wi-Fi 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001
networksetup -getdnsservers Wi-Fiscutil --dns shows the resolvers macOS really uses, including ones a VPN added. -getdnsservers shows the manual list for one service, and saying there are none means the service takes its servers from DHCP. Use networksetup -listallnetworkservices if your service is not called Wi-Fi.
To roll back, set the addresses you recorded with -getdnsservers again using -setdnsservers. If the service had no manual servers before, run sudo networksetup -setdnsservers Wi-Fi empty instead, which returns it to the servers DHCP provides. In the app, the setting is in System Settings, Network, your service, Details, DNS.
Change the DNS Server on Linux
Change the DNS server on Linux in the tool that owns /etc/resolv.conf, or the change disappears at the next lease renewal or reboot.
Depending on the distribution, DNS may be managed by NetworkManager, systemd-networkd through netplan, a DHCP client or a manually maintained file. The first two commands show the resolver file and the systemd-resolved status, which exists only where systemd-resolved runs. The last two show whether NetworkManager or systemd-networkd manages the active connection.
ls -l /etc/resolv.conf
resolvectl status
nmcli connection show --active
networkctl status| If resolv.conf is | Manager | Where to change DNS |
|---|---|---|
A link to /run/systemd/resolve/stub-resolv.conf | systemd-resolved, fed by netplan, NetworkManager or systemd-networkd | The tool that configures the interface, often netplan on Ubuntu Server |
| Written by NetworkManager | NetworkManager | nmcli connection modify |
| A plain file nobody rewrites | Nobody | Edit /etc/resolv.conf directly |
For a quick test on systemd-resolved, set servers on one link. This lasts until the link is reconfigured or the machine reboots, and revert undoes it.
sudo resolvectl dns eth0 1.1.1.1 1.0.0.1 2606:4700:4700::1111
resolvectl status eth0
resolvectl query example.com
sudo resolvectl revert eth0For a permanent change with NetworkManager, record the current DNS and automatic DNS values first, then set yours and reconnect. The connection name comes from nmcli connection show.
nmcli -g ipv4.dns,ipv4.ignore-auto-dns,ipv6.dns,ipv6.ignore-auto-dns connection show 'Wired connection 1'
sudo nmcli connection modify 'Wired connection 1' ipv4.dns '1.1.1.1 1.0.0.1' ipv4.ignore-auto-dns yes ipv6.dns '2606:4700:4700::1111' ipv6.ignore-auto-dns yes
sudo nmcli connection up 'Wired connection 1'To roll back, set the four recorded values again with nmcli connection modify and reconnect. If DNS came from DHCP before, clear the DNS fields with empty quotes and set both ignore-auto-dns options to no. On Ubuntu Server with netplan, DNS servers sit under nameservers in the netplan file, as shown in setting a static IP on Ubuntu Server with Netplan.
The same applies on a server. On VPS hosting with root access, you own the resolver list, so a dead entry left over from an old image or provider is yours to remove.
Troubleshoot DNS Forwarders on a Server
Troubleshoot DNS forwarders on a server that runs its own caching resolver, since every client then inherits its upstream delays.
A recursive resolver looks names up for clients and caches the answers. An authoritative server holds the records for a domain and answers only for it. A forwarder is a resolver that passes cache misses to another resolver upstream instead of walking from the root itself.
dig @127.0.0.1 example.com +stats
dig @203.0.113.53 example.com +tries=1 +time=2 +stats
resolvectl statisticsThe first line times the local resolver, the second times one upstream forwarder directly, with 203.0.113.53 standing in for each upstream address in your config. A dead upstream causes the same timeouts as a dead client server. Use resolvectl statistics only where systemd-resolved is the local cache. For BIND, Unbound or dnsmasq, check that resolver's own cache statistics and logs.
Conditional forwarders, which send one internal domain to its own DNS servers, must point at servers that answer. A slow one slows only that domain, which looks like the one domain pattern above.
Fix Slow DNS on a Router or Whole Network
Fix slow DNS on the router when every device on the network is slow, because the router usually hands out the DNS server.
- Sign in to the router admin page, often at your default gateway address such as
192.168.1.1. - Find the DNS settings for the internet (WAN) side and for DHCP, and write down the current values.
- Enter the new resolver addresses, including the IPv6 DNS fields if your connection has IPv6.
- Save, then reconnect a device so it gets a fresh lease and the new servers.
- Run the dig test from that device and compare with your first measurement.
Some routers give out their own address as the DNS server and forward queries upstream. In that case the device list looks unchanged, and the dig test is how you see the difference. Some internet providers lock DNS on their equipment, so set DNS on each device instead.
IPv6 DNS can arrive separately, through router advertisements or DHCPv6. If the IPv4 settings look right but lookups still stall, check the IPv6 DNS settings on the router, because a device can get a different resolver over IPv6.
If anything breaks, put back the values you wrote down. Restarting the router may clear its DNS cache or temporary stuck states, but it does not fix a slow upstream server.
Flush DNS Caches After a Fix
Flush local DNS caches after a fix to remove locally stored answers, then measure again.
An upstream resolver may still have the same answer cached until its TTL runs out.
| System | Command |
|---|---|
| Windows | ipconfig /flushdns or Clear-DnsClientCache |
| macOS | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
| Linux with systemd-resolved | sudo resolvectl flush-caches |
| Chrome | chrome://net-internals/#dns then Clear host cache |
| Edge | edge://net-internals/#dns then Clear host cache |
Flushing does not make DNS faster. It removes stored answers, so the next lookup of each name is a cold one. It helps when a cache holds a wrong or "does not exist" answer, and it makes your next test honest.
Every record has a TTL (time to live), which sets how long resolvers may reuse a cached answer. A record with a very low TTL sends resolvers back upstream often, so check it, shown as the number after the name in dig output, before blaming your resolver for repeated cache misses.
Choose a Faster DNS Resolver
A faster DNS resolver is the one with the lowest cold lookup time from your own network, which only a test from there can show.
| Resolver | IPv4 | IPv6 |
|---|---|---|
| Cloudflare 1.1.1.1 | 1.1.1.1, 1.0.0.1 | 2606:4700:4700::1111, 2606:4700:4700::1001 |
| Google Public DNS | 8.8.8.8, 8.8.4.4 | 2001:4860:4860::8888, 2001:4860:4860::8844 |
| Your provider or router | From DHCP | From DHCP or router advertisements |
Test each candidate with at least 10 new names under a domain you control, so no cache helps, and compare the median and the number of timeouts.
D=yourdomain.example; for s in 1.1.1.1 8.8.8.8 203.0.113.53; do for i in $(seq 10); do q="t$(date +%s%N)-$i.$D"; dig @"$s" "$q" +tries=1 +time=2 +noall +comments +stats | awk -v s="$s" -v q="$q" '/status:/ {st=$6; sub(",", "", st)} /Query time/ {print s, q, st, $4, "ms"; found=1} END {if (!found) print s, q, "TIMEOUT"}'; done; doneA shortened real run on Ubuntu 24.04.5, with two queries each against 8.8.8.8 and the silent test listener at 127.0.0.77, using example.com as the domain, printed this. The third column is the DNS status of each reply.
8.8.8.8 t1796296096362122135-1.example.com NOERROR 16 ms
8.8.8.8 t1796296096406207189-2.example.com NOERROR 16 ms
127.0.0.77 t1796296096466179548-1.example.com TIMEOUT
127.0.0.77 t1796296098497768760-2.example.com TIMEOUTReplace yourdomain.example with your domain and 203.0.113.53 with your current resolver. A query with no normal reply within the timeout prints TIMEOUT, so count those rather than leaving them out. Repeat with AAAA added after the name, and run the test at different times of day before you settle. Results depend on your location and network, so a resolver that wins in one place can lose in another. The test network for this guide routes all DNS through one resolver, so no ranking from it is given here.
Also check TCP, which DNS uses for large answers. dig +tcp @1.1.1.1 example.com should answer like UDP. On the test machine outbound TCP port 53 was blocked by its network, and dig showed connection refused and no servers could be reached, which is what a blocked TCP path looks like.
Verify the DNS Fix and Know What It Proves
Verify the DNS fix with the same tests on the same device, and know what a pass proves before you call it done.
- The DNS server list shows only servers that answer.
- A new, uncached name gets a DNS response in a cold time close to your best resolver test. Check the status and answer section too, since NOERROR can come with an empty answer and NXDOMAIN means the name does not exist.
- Both
dig Aanddig AAAAanswer quickly. - In the curl timing, the
dnsphase takes up only a small share of the total.
A pass proves the resolver path is healthy for that device and network today. It does not prove a slow site is fixed, because the delay can be in the connection, TLS or the server. A browser with secure DNS (DNS over HTTPS) turned on can also use its own resolver, so check that setting if the browser stays slow while tests pass.
Slow DNS Lookup Troubleshooting Table
This slow DNS lookup troubleshooting table maps common test results to a cause and a next step.
| Result | Likely cause | Next step |
|---|---|---|
| Every lookup takes about 5 s on Linux | Dead first server and glibc default timeout | Test each server with +tries=1 +time=2 and remove the dead one |
dig fast, programs slow | AAAA dropped, or a local cache or hosts entry | Run dig AAAA and check the hosts file |
| Cold lookups over a few hundred ms | Distant or busy resolver | Compare resolvers with the loop above |
| One domain slow from every network | Its authoritative nameservers | Ask each NS directly, then tell the domain owner |
| Fast after flush, slow again later | Resolver or router cache faults | Change the resolver, update router firmware |
| Slow with VPN on only | DNS servers set by the VPN | Check scutil --dns or Get-DnsClientServerAddress with it on |
dig +tcp fails while UDP works | TCP port 53 blocked on the path | Allow outbound TCP 53 to your resolver |
| Queries time out over UDP and TCP | Firewall or network filtering | Allow outbound UDP and TCP 53 to the resolver you use |
Questions people ask
How do I fix slow DNS lookup?
Time a lookup with dig or Resolve-DnsName first. Then remove any DNS server that does not answer, switch to a resolver that tests fast from your network, flush caches and measure again.
Why does a DNS lookup take 5 seconds?
On Linux it usually means the first server in resolv.conf is dead. glibc waits its default 5 second timeout before trying the next server.
How do I flush my DNS cache?
Use ipconfig /flushdns on Windows, dscacheutil with killall on macOS and resolvectl flush-caches on Linux with systemd-resolved. Browsers keep their own cache too.
Is 1.1.1.1 still the fastest DNS?
It is fast in many places, but no resolver is fastest everywhere. Test it against 8.8.8.8 and your current resolver from your own network.
Can DNS cause slow internet speeds?
DNS delays the start of each new connection, not download speed. A slow resolver makes pages feel slow to begin loading while speed tests still look normal.
How do I fix DNS lookup failure?
Test the configured server with dig or Resolve-DnsName. If it times out, try another resolver and check that a firewall, VPN or router is not blocking port 53.
Why does DNS resolution time out on a VPS?
Usually a dead upstream resolver in /etc/resolv.conf, a firewall blocking outbound port 53, a broken forwarder or a dead IPv6 DNS server. Test each server one by one.
Should I disable IPv6 to fix slow DNS?
Not as a first step. Check whether AAAA queries get answers, then fix or replace the resolver or router that drops them.
Sources
- resolv.conf(5), Linux manual page
- RFC 8305, Happy Eyeballs Version 2
- Microsoft Learn, Set-DnsClientServerAddress
- Microsoft Learn, Resolve-DnsName
- NetworkManager, nm-settings-nmcli (ipv4.dns, ipv6.dns, ipv4.ignore-auto-dns and ipv6.ignore-auto-dns)
- systemd, resolvectl manual
- Apple Support, Change DNS settings on Mac
- Cloudflare, 1.1.1.1 IP addresses
- Google Public DNS, Get started