How to Migrate cPanel Accounts Between Servers Using WHM Transfer Tool (Zero-Downtime Guide) Moving live…
DNS Resolution Failure Linux: Troubleshooting Guide

DNS Resolution Failure Linux: How to Diagnose and Fix DNS Issues
A DNS resolution failure Linux issue occurs when a Linux server cannot translate a domain name into an IP address. For example, a server may have a working internet connection but fail to access example.com because its DNS resolver cannot return the correct IP address.
This problem can affect website availability, API requests, package installations, email delivery, database connections, and applications that depend on external services. Common symptoms include Temporary failure in name resolution, Could not resolve host, and DNS query timeouts.
In this guide, you will learn how to diagnose DNS resolution problems on a Linux VPS, inspect resolver settings, test DNS servers, troubleshoot systemd-resolved, identify network-related failures, and apply safe fixes without unnecessarily changing your server configuration.
What Causes DNS Resolution Failure on Linux?
Before changing any configuration, identify the likely cause. A DNS resolution failure Linux problem can originate from the local resolver, network connectivity, DNS server availability, firewall rules, or incorrect DNS records.
Common causes include:
- Incorrect or missing nameserver entries.
- A stopped or misconfigured
systemd-resolvedservice. - DNS server timeouts or unreachable nameservers.
- Incorrect
/etc/resolv.confconfiguration. - Firewall rules blocking DNS traffic over UDP or TCP port 53.
- Invalid domain records or DNS propagation issues.
- Broken IPv4 or IPv6 connectivity.
- Container-specific DNS configuration problems.
- DNS caching that returns outdated information.
The correct solution depends on where the lookup fails. Start with basic connectivity and DNS tests before editing system files.
Step 1: Confirm the DNS Resolution Error
First, reproduce the issue using a domain that should resolve.
Run:
getent hosts example.com
If the command returns an IP address, the system’s name lookup mechanism is working for that domain. If it returns nothing, further investigation is required.
Next, try:
ping -c 3 example.com
If the output contains a message such as:
ping: example.com: Temporary failure in name resolution
the hostname could not be resolved.
However, a failed ping does not always indicate a DNS problem. Some servers block ICMP traffic. Test network connectivity separately:
ping -c 3 1.1.1.1
If the IP address responds but the domain name does not, DNS is a likely cause. If neither responds, investigate routing, firewall rules, and network connectivity before assuming DNS is the only problem.
You can also check the server’s IP configuration:
ip address
ip route
Look for an active network interface and a valid default route.
Step 2: Test DNS Using dig and nslookup
The dig utility provides detailed DNS query results and is useful for distinguishing resolver failures from DNS server problems.
Check whether it is installed:
command -v dig
If unavailable, install the appropriate package for your distribution.
On Ubuntu or Debian:
sudo apt update
sudo apt install dnsutils
On RHEL-compatible distributions that use DNF:
sudo dnf install bind-utils
Now query a domain:
dig example.com
Check the status field in the output. A successful response commonly shows:
status: NOERROR
The ANSWER SECTION should contain the requested DNS record when one exists.
Other useful response codes include:
NXDOMAIN: The queried domain name does not exist according to the responding DNS server.SERVFAIL: The server could not complete the DNS query successfully.REFUSED: The server refused to answer the query.NOERRORwith no answer: The query succeeded, but the requested record may not exist for that name and record type.
To test only the A record:
dig example.com A
To test an IPv6 AAAA record:
dig example.com AAAA
You can also use nslookup if it is available:
nslookup example.com
These commands help establish whether the failure affects all DNS queries or only a particular domain or record type.
Step 3: Test a Specific DNS Server
Your configured DNS resolver may be unavailable or incorrectly configured. Query a known public DNS resolver directly to compare the results.
For Cloudflare DNS:
dig @1.1.1.1 example.com
For Google Public DNS:
dig @8.8.8.8 example.com
Interpret the results carefully:
- If the default query fails but a direct query succeeds, investigate the configured resolver and local DNS settings.
- If both queries time out, check outbound network connectivity, firewall rules, and whether direct DNS queries are permitted by your hosting provider.
- If only one domain fails, investigate that domain’s DNS records, authoritative nameservers, and delegation.
- If the direct query returns
SERVFAIL, further investigation may be needed on the resolver or authoritative DNS side.
Direct queries are diagnostic tests, not necessarily a permanent solution. Some networks intentionally block external DNS requests and require you to use their designated resolver.
Step 4: Inspect the /etc/resolv.conf File
Linux applications commonly use /etc/resolv.conf to determine which DNS nameservers to query. Inspect the file:
cat /etc/resolv.conf
A basic configuration might contain:
nameserver 1.1.1.1
nameserver 8.8.8.8
Your actual configuration may instead point to a local stub resolver, such as 127.0.0.53, or another local address. That can be normal when a resolver service manages DNS.
Check whether the file is a symbolic link:
ls -l /etc/resolv.conf
Then inspect the file’s ownership and permissions:
stat /etc/resolv.conf
Do not immediately overwrite this file. On many systems, NetworkManager, systemd-resolved, DHCP, or another network service manages it. Manual edits may be overwritten or may break the resolver setup.
If the file is empty, contains an invalid nameserver, or points to an unavailable local resolver, identify which service manages it before making changes.
Step 5: Troubleshoot systemd-resolved
On Ubuntu and some other Linux distributions, systemd-resolved provides local DNS resolution and caching.
Check its status:
systemctl status systemd-resolved
If the service is inactive or failed, inspect its recent logs:
sudo journalctl -u systemd-resolved -n 100 --no-pager
You can also inspect the resolver’s current configuration:
resolvectl status
Test DNS through the system resolver:
resolvectl query example.com
If the service is expected to be enabled but is stopped, review the logs and configuration first. If appropriate for your distribution, start it with:
sudo systemctl start systemd-resolved
If the service should start automatically at boot, enable it after confirming that the system uses this resolver:
sudo systemctl enable systemd-resolved
Avoid enabling or restarting systemd-resolved blindly on servers that use a different DNS management system.
Check the local DNS stub resolver
A common configuration uses this entry in /etc/resolv.conf:
nameserver 127.0.0.53
This address is a local stub resolver used by systemd-resolved. If the file points to that address but the service is unavailable, DNS queries may fail.
Compare the symbolic link and resolver status:
ls -l /etc/resolv.conf
resolvectl status
systemctl is-active systemd-resolved
If they do not match the expected configuration for your distribution, correct the resolver setup using the appropriate network management method rather than replacing the file without checking its purpose.
Step 6: Check DNS Configuration Managed by NetworkManager
Some Linux servers use NetworkManager to configure network interfaces and DNS servers.
Check whether NetworkManager is running:
systemctl status NetworkManager
Inspect active connections:
nmcli connection show --active
Display DNS information for a connection:
nmcli device show
Look for IP4.DNS and IP6.DNS entries.
If a connection has an incorrect DNS configuration, identify the exact connection name first:
nmcli connection show
You can then configure a connection to use approved DNS servers. For example, after replacing YOUR_CONNECTION with the correct connection name:
sudo nmcli connection modify "YOUR_CONNECTION" \
ipv4.dns "1.1.1.1 8.8.8.8"
This example is appropriate only if those resolvers are permitted and suitable for your environment. For DHCP-managed connections, check whether automatic DNS configuration should remain enabled or be overridden.
Apply the change during an appropriate maintenance window, because modifying network connections can interrupt connectivity:
sudo nmcli connection up "YOUR_CONNECTION"
If you are connected remotely over SSH, be especially careful. A network reconnection may disconnect your session.
Step 7: Check DNS Timeouts and Firewall Rules
If DNS queries hang instead of returning an answer, test whether the configured resolver is reachable.
Use:
dig example.com +time=3 +tries=1
A timeout means no usable response arrived within the query period. It does not, by itself, prove that a firewall is responsible.
DNS normally uses UDP port 53 and can also use TCP port 53. TCP is important for certain responses and DNS operations, so a firewall that blocks it can cause problems even when ordinary queries appear to work.
Inspect the firewall rules using the firewall system installed on your server.
For UFW:
sudo ufw status verbose
For nftables:
sudo nft list ruleset
For firewalld:
sudo firewall-cmd --list-all
Check outbound DNS restrictions, local resolver rules, and any network-level firewall configured by your hosting provider. Do not flush firewall rules or disable the firewall as a quick test on a production server.
If packet-level analysis is necessary and tcpdump is installed, you can observe DNS traffic:
sudo tcpdump -ni any port 53
Run a DNS query in another terminal and check whether requests leave the server and whether replies return. Be aware that this command may display DNS query information, so use it appropriately.
Step 8: Check DNS Records and Authoritative Nameservers
If public domains resolve correctly but one particular domain fails, the problem may be with that domain rather than your Linux server.
Query the domain’s nameservers:
dig example.com NS
Check its A record:
dig example.com A
Check the record from a specific resolver:
dig @1.1.1.1 example.com A
For a more detailed investigation, use:
dig +trace example.com
A trace follows the DNS delegation path from the DNS root toward the domain’s authoritative servers. It can help identify delegation problems, missing records, or failures along the path. However, it may be affected by network restrictions and does not replace checking the authoritative DNS provider’s configuration.
For a domain you manage, verify that:
- The domain has the required A or AAAA records.
- The registered nameservers match the intended DNS provider.
- The authoritative DNS zone contains the expected records.
- DNSSEC configuration is valid when DNSSEC is enabled.
- Recent DNS changes have had enough time to propagate through caches.
Remember that different resolvers may temporarily return different results because of caching and TTL values.
Step 9: Flush or Refresh DNS Caches
Cached DNS responses can sometimes make a recent change appear inconsistent. First identify which resolver or caching service is actually in use.
For systemd-resolved, clear its cache with:
sudo resolvectl flush-caches
Then test again:
resolvectl query example.com
For systems running nscd, check its status:
systemctl status nscd
If nscd is active and managing host lookups, its cache may be refreshed by restarting the service, but do this only when appropriate for your server.
Not every Linux server has a local DNS cache. Flushing a local cache will not remove cached records from public DNS resolvers or remote clients.
Step 10: Verify the Fix
After making a change, repeat the same tests that originally failed.
Start with:
getent hosts example.com
dig example.com
If systemd-resolved manages DNS, also run:
resolvectl query example.com
resolvectl status
Finally, test the application or service that experienced the problem. For example, you can verify HTTPS connectivity with:
curl -I --connect-timeout 10 https://example.com
A successful DNS lookup does not guarantee that the website or application is healthy. If the hostname resolves but the connection fails, investigate routing, TLS certificates, ports, web server status, and application logs separately.
Common DNS Troubleshooting Commands
| Command | Purpose |
|---|---|
getent hosts example.com |
Test system hostname resolution |
dig example.com |
Inspect DNS query results |
dig @1.1.1.1 example.com |
Test a specific DNS resolver |
dig +trace example.com |
Investigate DNS delegation |
cat /etc/resolv.conf |
Inspect resolver configuration |
resolvectl status |
Inspect systemd-resolved settings |
resolvectl query example.com |
Test the system resolver |
ip route |
Check routing and the default route |
journalctl -u systemd-resolved -n 100 |
Inspect resolver service logs |
Replace example.com with the affected hostname when running these commands.
Frequently Asked Questions
Why does Linux show “Temporary failure in name resolution”?
This message usually means the system could not obtain a usable DNS response for the hostname. Check /etc/resolv.conf, the configured nameserver, network connectivity, and the status of the resolver service.
Why can I ping an IP address but not a domain name?
This often indicates that basic IP connectivity works while DNS resolution is failing. Compare ping -c 3 1.1.1.1 with getent hosts example.com and dig example.com to narrow down the cause.
Is it safe to change nameservers to 8.8.8.8 or 1.1.1.1?
These are public DNS resolver addresses, but they are not automatically the right choice for every server. Some hosting providers require their own resolvers, and private networks may depend on internal DNS records. Confirm your network requirements before changing nameservers.
Why does DNS work with dig but fail in an application?
dig can query a DNS server directly, while applications commonly use the system’s name service configuration. Compare a direct dig query with getent hosts and inspect the resolver configuration to identify the difference.
Will restarting the server fix DNS resolution problems?
A restart may temporarily restore a failed service, but it does not identify the underlying cause. Check resolver status, configuration, logs, and network settings first whenever possible.
Conclusion
A DNS resolution failure Linux problem can originate from resolver configuration, unreachable nameservers, DNS timeouts, firewall rules, or incorrect domain records. The most reliable approach is to test system resolution, query a specific DNS server, inspect /etc/resolv.conf, and review the service responsible for managing DNS.
Make changes only after identifying the failing component, then repeat your original tests to confirm that resolution has recovered. This approach helps prevent unnecessary network changes and reduces the risk of interrupting production services.
If you need a Linux VPS for hosting websites, applications, or infrastructure workloads, explore the available ServerNext VPS solutions and visit ServerNext for more information.
