Skip to content
On this page

Fix NXDOMAIN for new subdomains

When creating a new subdomain (like sub.example.com) and setting the A record, I could not open the page on my Ubuntu machine for days— even though DNS is already active globally.

On Chrome I may get the error message DNS_PROBE_FINISHED_NXDOMAIN while on Firefox it just shows error. The reason is that it cannot find a DNS settings for that domain. Ubuntu uses systemd-resolved via 127.0.0.53, which sometimes caches outdated or missing DNS entries too aggressively.

Quick test

Use an external DNS resolver directly:

bash
dig sub.example.com @8.8.8.8

→ If that works but dig sub.example.com without @8.8.8.8 returns NXDOMAIN, your local DNS is outdated.

Persistent fix

Tell Ubuntu to use public DNS resolvers.

Edit:

bash
sudo nano /etc/systemd/resolved.conf

Set in the [Resolve] block:

ini
DNS=8.8.8.8
FallbackDNS=1.1.1.1
  • 8.8.8.8 = Google DNS (fast and reliable)
  • 1.1.1.1 = Cloudflare DNS (privacy-focused fallback)

Restart the resolver:

bash
sudo systemctl restart systemd-resolved

Now dig sub.example.com should work normally again.