This content is viewable by Everyone
How to Flush DNS Cache
- Owner Team: Developer Experience Team
-
Service:Developer Services
When troubleshooting network connectivity issues or addressing DNS-related errors, one of the most common and effective first steps is to flush the DNS cache. This process clears outdated or corrupted DNS entries, allowing your system to fetch the most up-to-date DNS information from configured servers.
This guide will walk you through how to flush the DNS cache on macOS, Windows, and Linux systems.
What Is a DNS Cache?
A DNS (Domain Name System) cache is a local database your computer uses to store information about websites you've previously visited—specifically the domain names and their corresponding IP addresses. This speeds up subsequent visits by avoiding repeated lookups through your DNS servers.
However, over time, this cache may become outdated or corrupted. For instance:
- A website may have changed its IP address.
- Malicious software might have modified DNS entries.
- Cached data may be causing conflicts or load errors.
Clearing or “flushing” the DNS cache resolves many of these issues.
Why Flush the DNS Cache?
At UCSF, you may be asked to flush your DNS cache by IT support as part of a troubleshooting process. Reasons include:
- Incorrect or outdated DNS entries are preventing access to UCSF resources or external websites.
- Slow browsing or loading issues, especially for known-good websites.
- Security or privacy concerns, such as removing traces of previously visited sites on a shared or public computer.
- "DNS server not responding" or related errors while attempting to browse the internet.
Prerequisites
To perform a DNS flush, you’ll need:
- A UCSF-managed or personal computer running Windows, macOS, or Linux.
- Administrator or root access to the system.
- Access to the terminal (macOS/Linux) or Command Prompt (Windows).
Instructions by Operating System
macOS
For macOS Sonoma (version 14) and newer:
- Open Terminal (Applications > Utilities).
Run the following command:
sudo killall -HUP mDNSResponder
- When prompted, enter your administrator password. To hear an audible confirmation (optional): sudo killall -HUP mDNSResponder; say "DNS cache flushed"
For older macOS versions:
- macOS Mojave (10.14) through Lion (10.7): sudo killall -HUP mDNSResponder
macOS El Capitan (10.11), Mavericks (10.9): sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
macOS Yosemite (10.10): sudo discoveryutil mdnsflushcache
sudo discoveryutil udnsflushcaches
Mac OS X Snow Leopard (10.6) and earlier:
sudo dscacheutil -flushcache
Windows
Windows 8, 10, and 11:
- Open Command Prompt as Administrator:
- Search for "Command Prompt" in the Start Menu.
- Right-click and select Run as administrator.
Enter the command:
ipconfig /flushdns
- You’ll receive a message confirming the DNS Resolver Cache was successfully flushed
Windows 7, Vista, XP:
- Go to Start > All Programs > Accessories.
- Right-click on Command Prompt and select Run as administrator.
Enter the same command:
ipconfig /flushdns
Linux
Linux systems may use different DNS caching mechanisms. First, determine which DNS service is active:
sudo lsof -i :53 -S
If using systemd-resolved (common in Ubuntu 18.04+):
sudo resolvectl flush-caches
Verify the cache was cleared:
resolvectl statistics
If using nscd :
sudo systemctl restart nscd.service
Or, for SysVinit systems:
sudo service nscd restart
If using dnsmasq:
sudo killall -HUP dnsmasq
Or, restart the service:
sudo systemctl restart dnsmasq
If using BIND:
sudo rndc restart
Or to flush without restarting:
sudo rndc flush
To flush a specific domain:
sudo rndc flushname yourdomain.ucsf.edu