What exactly is DNS refresh?
When a website that has just switched servers is inaccessible while others say everything is working fine; when you change your network settings on your computer but they don't take effect, the most common advice in technical documentation is: "Refresh your DNS cache." This seemingly technical operation, what exactly does it mean? Why does it solve the problem? To understand it, we need to start with a crucial, unseen step in our daily internet browsing.
Address Book and Sticky Notes
You can think of the internet as a vast city that only recognizes numerical addresses (IP addresses, such as `142.250.74.110`), while we humans are accustomed to using names (domain names, such as `google.com`) to remember locations. DNS (Domain Name System) is the most important public service in this city—it's a super telephone directory, dedicated to finding the precise numerical address corresponding to the name "Google."
However, if every time you want to access Google, your computer had to queue up at the city's central "main telephone exchange" (the DNS root server) for a lookup, then browsing the internet would become extremely slow. To solve this problem, your computer, router, and even your internet service provider have learned to do something smart: caching.
Specifically, when your computer successfully accesses `google.com` for the first time, it looks up the corresponding IP address through DNS. After the access is complete, it doesn't immediately discard this result; instead, it treats it as a "note," recording it in a temporary local notebook (DNS cache) and setting an expiration date. In the next few minutes or hours, when you want to access Google again, your computer will first check its "notebook." If the record is still valid, it will use that address directly, without disturbing the "main exchange." This mechanism greatly improves our internet speed and efficiency, reducing duplicate query requests.
The Real Meaning of "Refreshing"
Now we can answer the core question: refreshing DNS means clearing all the old "notebook" records in your device's local notebook.
Why do we need to clear it? Because the information in the "main exchange" (i.e., the real IP address corresponding to the domain name) can change. A common scenario is website migration. Imagine a website has moved from a US server to a Hong Kong server. Its new address (new IP) registered with the DNS (Internet Protocol version 2.0) has been updated. However, your computer is unaware of this; its DNS cache still has a "note" with the old US address. When you try to access the website, your computer will still eagerly go to the now-empty old address, resulting in "inaccessible."
Refreshing the DNS cache is like tearing off that expired "note" from your cache. The next time you try to access the website, your computer will find no record in its cache and will be forced to query the DNS cache again to get the latest and most correct address.
Therefore, refreshing DNS is not a "repair" action, but a "reset" or "forced update" action. Its core purpose is to clear outdated, incorrect, or conflicting DNS resolution records from your local DNS server, forcing the system to obtain the latest information from an authoritative source.
Where does the refresh happen?
Understanding the principle, we can see that this "little notebook" exists at multiple levels, and the location of the refresh determines the scope of the impact:
1. Operating System Cache: This is the most frequently accessed level, existing within your Windows, macOS, or Linux computer. Clearing this cache only affects the current computer.
2. Browser Cache: Modern browsers like Chrome and Firefox also have their own independent DNS caches to load web pages faster. Sometimes it's necessary to clear the browser's history and cache separately.
3. Router Cache: Your home or office router also acts as a DNS lookup relay, and it similarly caches records. Refreshing or restarting the router can clear this cache, affecting all devices on the entire local area network.
4. ISP Cache: Your internet service provider (such as China Telecom or China Mobile) has a wider range of cache servers. Individual users cannot directly refresh these caches and usually need to wait for them to expire naturally (TTL expiration).
How to Perform a Refresh
The refresh operation needs to be completed by entering specific commands in the command-line terminal. The following are general methods for refreshing the local DNS cache across different operating systems. Please open the corresponding command-line tool and execute the following commands:
On Windows:
Use the command prompt (run as administrator). The most classic and effective command is:
ipconfig /flushdns
After successful execution, you will see the message "DNS resolution cache successfully refreshed." For Windows 10/11, sometimes you can additionally restart the DNS client service:
net stop dnscache && net start dnscache
On macOS:
Open a terminal. The command varies depending on the system version. For newer versions (macOS Big Sur and later), the most reliable command is:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
You will need to enter your administrator password to complete the operation.
On major Linux distributions:
Open a terminal. Since Linux uses different DNS services, the command depends on your system. The most common method is to use the `systemd-resolved` service, with the command:
sudo systemd-resolve --flush-caches
If the system uses `nscd` (the Name Service Cache daemon), use:
sudo systemctl restart nscd
or
sudo service nscd restart
When is a refresh needed?
Having understood "what" and "how," the final step is to clarify "when to use." Refreshing the DNS cache is usually an effective first step in troubleshooting in the following situations:
Inaccessible website after migration or IP change: This is the most typical scenario, as mentioned above.
Website resolution errors: Errors such as "DNS_PROBE_FINISHED_NXDOMAIN" are displayed.
After modifying the local Hosts file: The Hosts file is a local file that manually specifies domain name and IP mappings. Refreshing the cache after modification ensures that the new rules take effect immediately, which is commonly used in development and testing.
Encountering DNS poisoning or hijacking: Some malware or network environments can tamper with your DNS results. Refreshing the cache may temporarily clear erroneous records. Connectivity issues may arise after a network switch: for example, some websites may be inaccessible after switching from a company network to a home network.
However, refreshing the local cache is not a panacea. If the problem lies upstream (such as incorrect DNS settings on your router, a DNS server malfunction by your internet service provider, or incomplete global synchronization of the website's domain registration records), then refreshing the local cache will not solve the problem. In this case, you can try manually changing your computer's DNS server to a public DNS (such as `8.8.8.8` or `1.1.1.1`), which is equivalent to switching to a more reliable and cleaner "main exchange" for querying, and then refreshing the cache again.
In short, refreshing DNS is a simple yet crucial basic networking skill. It doesn't change any network settings or fix complex hardware problems; it simply resets your local "address book," clearing the way for the latest and correct network addresses. The next time you encounter the strange phenomenon of "others can access the internet but I can't," try executing this simple refresh command first; it may very well be the key to a smooth network connection.
CN
EN