What the message looks like
$ dig example.com
;; communications error to 192.0.2.53#53: timed out
;; communications error to 192.0.2.53#53: timed out
;; no servers could be reachedCommon causes
- The configured DNS server address is wrong or the server is down.
- A firewall drops UDP and TCP port 53, on the client, the server or in between.
- The DNS service (
named,unbound,dnsmasq) does not run or listens only on another interface. - No route to the server, for example a VPN or network change.
- Large answers need TCP, and only UDP is allowed.
Check
- Which server does the system use?
resolvectl status - Same query against a public resolver. Does the network work at all?
- Query over TCP instead of UDP
dig example.com @192.0.2.53 +tcp +time=3 +tries=1 - On the DNS server: does it listen on port 53?
sudo ss -lunpt | grep ':53 '
Fix
- If the query to a public resolver works, the configured server is the problem: replace it or repair it.
- If nothing works, fix the network first: route, gateway, VPN, cable.
- On your own DNS server, start the service (
sudo systemctl status unboundornamed) and check that it listens on the interface the clients use. - Allow port 53 for UDP and TCP in the firewall in both directions as needed. Allow it only from the networks that need it.
- If only TCP fails, answers may be big or cut. Allow TCP 53, do not block it.
Typical scenario
An admin swaps the internet router. Since then dig example.com on the Linux server prints three communications error ... timed out lines, while a laptop on the same network resolves fine. The server still has the old router's address hard-coded as its only nameserver in /etc/resolv.conf, and the new router answers on a different IP. First check: which address is really configured there, and does dig @1.1.1.1 work from this very server?
FAQ
Is the domain broken?
Probably not. No answer means the resolver or the path is broken. A broken domain gives an answer such as NXDOMAIN or SERVFAIL.
It works with 8.8.8.8 and not with my router.
Then the router or the upstream behind it is the problem. Set another resolver on the client to confirm, then fix or replace the router DNS.
How long does dig wait before giving up?
By default 5 seconds per attempt and up to 3 attempts per server. With two dead servers it takes well over half a minute before the error appears. For testing, +time=2 +tries=1 shows you quickly whether anything answers at all.
Is adding a second nameserver enough?
As a stopgap, yes, but the resolver tries entries in order. If the first one is dead, every lookup first waits for its timeout and everything feels slow. It is better to repair or remove the broken entry than to just append a fallback behind it.
How do I tell whether only UDP or also TCP is blocked?
Query the same server once normally and once with +tcp. If only TCP answers, something filters UDP packets on port 53. If neither answers, the server, the route or a firewall is fully closed. A test against 1.1.1.1 shows whether the client itself can reach out.