Flush Your DNS Cache: The 30-Second Fix for Linux Internet Slowdowns
Share this article
If your Linux workstation or server is crawling while other devices on your network perform flawlessly, the culprit might be hiding in plain sight: a corrupted DNS cache. As developers and sysadmins increasingly rely on Linux for critical workflows, understanding this fundamental networking component becomes essential. The Domain Name System (DNS) serves as the internet's phonebook, translating human-readable URLs like zdnet.com into machine-readable IP addresses. Your system's DNS cache stores recent lookups to accelerate future requests—but when this cache becomes corrupted, it can throttle your connectivity to a standstill.
Why DNS Caches Falter
DNS caches can develop issues through multiple pathways: conflicting IP mappings for single domains, malformed entries, outdated records after IP changes, or even minor software glitches. These problems manifest as painfully slow page loads, intermittent site crashes, or complete inability to access certain domains. What makes this particularly frustrating for technical users is that the issue appears isolated to a single machine despite identical network conditions.
The Systemd-Resolved Solution
Modern Linux distributions typically manage DNS caching through systemd-resolved. Here's how to diagnose and resolve cache issues in under 30 seconds:
- Verify Service Status: Confirm the resolver is active:
systemctl is-active systemd-resolved
An active response confirms caching is enabled.
- Check Current Cache Size: Establish a baseline with:
resolvectl statistics
Look for Current Cache Size in the output (e.g., 14 entries).
- Flush the Cache: Clear corrupt entries with:
resolvectl flush-caches
This command executes silently upon success.
- Verify Results: Confirm the flush completed:
resolvectl statistics
The cache size should now read 0.
When Flushing Isn't Enough
While this quick fix resolves many DNS-related slowdowns, persistent issues warrant deeper investigation. Consider these next steps:
- Verify DNS server configurations in /etc/resolv.conf
- Test alternative DNS providers like Cloudflare (1.1.1.1) or Google (8.8.8.8)
- Inspect for broader network issues using ping and traceroute
- Examine firewall rules that might interfere with DNS traffic
For Linux professionals, this simple flush technique should be the first troubleshooting step before diving into complex network diagnostics. As Jack Wallen notes in the original ZDNET article, this approach isolates machine-specific issues from broader network problems. While cloud-native development often abstracts lower-level networking, understanding these foundational layers remains crucial when debugging performance bottlenecks in development environments or production systems. Remember: A corrupted cache won't log obvious errors—it simply degrades performance silently until flushed.
Source: Slow internet speed on Linux? This 30-second fix makes all the difference (ZDNET)