What happens when a process looks up a name
/etc/resolv.conf. That file lists up to three nameserver lines, plus optional options such as timeout and attempts. Nothing on a typical cPanel box sits between applications and those upstream servers unless you installed a local caching resolver yourself.
When Exim, a PHP script, or a cPanel tool needs an address, it usually calls into the C library, for example getaddrinfo() in glibc. glibc reads /etc/resolv.conf, builds a DNS query, and sends it over UDP port 53 to the first nameserver in the list. Then it waits for a reply on that socket.
Three things can happen next:
- The resolver answers quickly with an address or a clean "this name does not exist" (NXDOMAIN). The lookup finishes in milliseconds.
- The resolver answers with an error such as SERVFAIL or REFUSED. glibc typically treats that as a reason to try the next nameserver. That costs a little time but no long wait.
- Nothing comes back. The packet was dropped, the resolver is overloaded, or the IP no longer runs a DNS service. glibc can't tell "slow" from "dead", so it waits the full timeout and then moves to the next server.
man resolv.conf, but check them on your distro. Also, glibc often sends the A and AAAA queries for a name together. If either reply goes missing, the whole call waits.
Why one dead resolver costs seconds on every lookup
How the delay stacks up in Exim, AutoSSL, and license checks
dns_retrans and dns_retry). It goes through the system resolver library, so a dead upstream still costs it time. When lookups time out instead of failing cleanly, Exim may treat them as temporary errors and defer the message. That shows up as a growing queue with retry entries, not hard bounces. Before clearing anything out of a queue like that, read the headers and logs as described in Exim Queue Full of Frozen Messages? Read the Headers Before Deleting Them. Resolver timeouts often show up there as DNS-related temporary errors.
AutoSSL works through many domains in one run. For each domain it resolves names, both for its own checks and to talk to the certificate provider. A server hosting hundreds of domains makes a lot of lookups per run, so a slow first resolver can stretch a run noticeably. It can also trigger timeouts that look like domain validation problems even when the domain's DNS is correct.
License verification and update checks are smaller jobs, but they have tight timeouts of their own. If the name of the remote endpoint takes too long to resolve, the tool reports that it can't reach its server, and people suspect a firewall or an outage on the vendor's side instead.
The common thread for support: when several unrelated services on one box get slow at the same time and none of them shows high CPU, test the resolvers before anything else.
Testing each resolver directly with dig
dig query against the default resolver isn't enough. dig picks its own server and its own timeout, and a single good answer can come from the healthy second entry. The useful test is to query every listed resolver by itself, with a short timeout and one try, so a dead entry shows up right away.
This loop reads the current list from /etc/resolv.conf and tests each entry. It's read-only and safe to run on a production server.
BASH
# Query each configured resolver on its own: short timeout, single try
for ns in (awk '/^nameserver/ {print2}' /etc/resolv.conf); do
echo "== $ns"
dig @"$ns" example.com A +time=2 +tries=1 | grep -E 'status:|Query time|timed out'
dig @"$ns" example.com AAAA +time=2 +tries=1 | grep -E 'status:|Query time|timed out'
donestatus: NOERROR and a low query time. A dead or unreachable one prints a timeout line.
TEXT
# Illustrative output format
== 192.0.2.10
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4120
;; Query time: 8 msec
== 192.0.2.20
;; connection timed out; no servers could be reachedtimeout and attempts options and the server order. To see the real cost through glibc, time a lookup via getent. It uses the same resolver path as most services on the box.
BASH
# Time a lookup through glibc, the same path Exim and cPanel tools use
time getent ahosts example.comReading the results and deciding what to change
/etc/resolv.conf to confirm the change landed, and run the getent timing again.
If an entry is 127.0.0.1 or the server's own IP, make sure something on the box actually answers recursive queries. On many cPanel servers the local DNS service is set up as an authoritative nameserver for hosted zones, not as a recursive resolver for the internet. In that setup it can answer for local domains and fail or refuse everything else. That depends on how the server was built, so test it with the dig loop and don't assume either way.
If an entry answers but slowly, for example hundreds of milliseconds every time, check whether it's far away on the network or rate-limiting you. A provider resolver in the same data center is usually faster and more predictable than a distant public one. Make that call from your measurements, not from the resolver's reputation.
If every entry times out, the problem probably isn't the resolvers. Look at outbound UDP and TCP on port 53 in the server firewall, upstream filtering, and general network reachability.
It's tempting to lower options timeout so failures cost less. That can be a reasonable trade-off, but it hides the dead resolver. A too-aggressive timeout can also turn slow but valid answers into failures. Fix the list first, then tune the timeout if you still need to.
The habit worth building is small. Run the per-resolver dig loop whenever a server is provisioned or migrated, and again whenever mail, AutoSSL, and license checks get slow together. Better still, run it on a schedule and alert on any entry that times out. It takes seconds, it's read-only, and it catches a resolver problem before it turns into a queue of deferred mail and a stack of tickets about a server that looks healthy.