Why this matters beyond the homelab: DNS failures rarely look like DNS failures. A page that fails once and loads on refresh points at a slow or wrong first lookup, and forced DNS redirection can loop a resolver’s own upstream traffic back to itself.
The Symptom
Google and other sites threw ERR_CONNECTION_CLOSED on the first load and worked after refreshing. Separately, the Apple TV intermittently warned that it had no network connectivity while it was streaming perfectly well.
Ruling Out the Obvious
The AdGuard Home query log came first. Queries for the failing sites were being processed and answered NOERROR, so AdGuard was not blocking anything. DNS was resolving, which moved the suspicion to something at the connection layer and made the cause harder to see.
The clue was in the same log. The upstream column showed queries going out to 8.8.8.8 over plain DNS on port 53. That was not the design. AdGuard had been set up to use DNS-over-HTTPS to Cloudflare and Quad9, and at some point the live configuration had drifted to plain DNS.
The Loop
The network also has a “Force DNS” rule on the UniFi gateway: a NAT redirect that sends any port 53 traffic from the LAN to AdGuard at 192.168.1.4. It exists to stop devices with hardcoded resolvers (smart TVs, speakers) from bypassing filtering, and it works well.
With AdGuard’s own upstreams on plain DNS, its outbound queries to 8.8.8.8:53 were also port 53 traffic, so the same rule redirected them straight back to AdGuard. The resolver was asking itself. First lookups timed out or failed. Repeats succeeded because the answer was eventually cached, which fits the refresh-fixes-it behavior exactly.
Two Fixes
- Switch the upstreams back to DoH. DoH travels on port 443, so the NAT rule never sees it.
- Exempt AdGuard’s own address from the Force DNS rule, so its outbound port 53 traffic isn’t redirected.
The first was quicker and matched the original design, so that’s the one I applied:
Upstream DNS:
https://1.1.1.1/dns-query
https://9.9.9.9/dns-query
Fallback DNS:
https://1.0.0.1/dns-query
https://149.112.112.112/dns-query
Everything on the network stays behind AdGuard’s filtering. The upstream setting only controls how AdGuard itself reaches the internet for names it doesn’t block.
The Lesson
A rule that applies to everything applies to the thing enforcing it, too. A catch-all redirect needs an explicit answer to “what about the resolver itself,” and the DoH design had been giving that answer implicitly the whole time, which is why nothing broke until the upstreams quietly changed. It’s also a drift story: the configuration I had documented was right, and the live configuration was not. The query log was what exposed the difference.
Related: Tailscale Split DNS and AdGuard: Remote Access Without Opening a Single Port | NPM and UniFi Firewall Rule Ordering: The Silent Traffic Drop | The Network Layer: Hardware, VLAN Segmentation, and Zero-Trust Firewall Design | Asking the Cluster Instead of the Documentation