Published on

What is DNS cache flushing?

Authors
  • avatar
    Name
    hwahyeon
    Twitter

DNS cache flushing is the process of clearing the DNS cache stored in the operating system. This allows DNS changes to be applied immediately and resolves connection issues.

When is DNS Cache Flushing Needed?

  1. When domain information changes: The server's IP address changes, but the cache retains the old IP, causing connection issues.
  2. To fix DNS errors: Errors like "DNS_PROBE_FINISHED_NXDOMAIN" can be resolved.
  3. When internet speed is slow: Corrupted cache data may cause delays in connections.
  4. To address security issues: Removes malicious cache data or resolves DNS hijacking problems.

How to Flush DNS Cache by Operating System

Windows

  1. Open the Command Prompt with administrator privileges.
  2. Enter the following command:
    ipconfig /flushdns
    
  3. If "Successfully flushed the DNS Resolver Cache" appears, the flush was successful. If the message does not appear, check the cache status with:
    ipconfig /displaydns
    

macOS

  1. Open the Terminal.
  2. Depending on your macOS version, use one of the following commands:
    • For macOS Yosemite and later (including the latest versions):
      sudo killall -HUP mDNSResponder
      
    • For macOS Yosemite and earlier:
      sudo dscacheutil -flushcache
      
  3. No success message may appear, but the cache will be cleared after running the command.

Linux

  1. Check if your Linux distribution manages DNS cache.
  2. Use the appropriate command based on the service managing DNS cache:
    • For systemd-resolved:
      sudo systemd-resolve --flush-caches
      
    • For nscd:
      sudo service nscd restart
      
  3. Note that some Linux distributions do not manage DNS cache by default, so flushing may not be necessary.

Resolving Issues with Public DNS

DNS caches managed by your ISP cannot be flushed by users. However, you can bypass these issues by using public DNS servers like Google Public DNS (8.8.8.8) or Cloudflare DNS (1.1.1.1).

How to Set It Up:

  1. In your network settings, change the primary DNS server to Google Public DNS (8.8.8.8) or Cloudflare DNS (1.1.1.1).
  2. This ensures faster application of DNS changes and bypasses potential ISP cache problems.

Important Notes

  1. Regular flushing is not necessary:
    • DNS caches are updated automatically, so regular flushing is not needed. However, it can be helpful in cases like static IP environments or internal networks with frequent DNS updates.
  2. Re-querying DNS after flushing:
    • After flushing, all domain requests will be sent to the DNS server anew. This may cause a slight delay for the first query.