You can view the contents of the DNS cache (from English "Domain Name System") using the "Terminal" or "Command Prompt" window on Mac and PC. Using a series of commands, the DNS client cache can be emptied. On mobile devices, it is possible to reset the cache using the "Use in airplane" mode. The data relating to the websites that are visited are stored in the DNS client cache, however when errors occur it may be impossible to access certain pages. Viewing or deleting the contents of the DNS service cache can help resolve these problems.
Steps
Part 1 of 3: Clear the DNS Cache on Smartphones and Tablets
Step 1. Close all applications before clearing the cache
On mobile devices, the contents of the DNS cache cannot be displayed, however it can be deleted to resolve any time-out problems relating to the request for web pages or related to the DNS service.
Make sure all internet browsers installed on your device are not running
Step 2. Enter the "Settings" menu
Scroll down the menu until you find "Wi-Fi".
If you are using an Android device, you need to refer to the "Wireless & Networks" section of the "Settings" menu
Step 3. Select the "Wi-Fi" tab, then turn off the "Wi-Fi" slider by moving it to the left
Wait until the data connection indicator appears in the upper left or right of the screen.
If you are using an Android device, tap the "Wi-Fi" slider to turn off the wireless network connection
Step 4. Re-enable Wi-Fi connectivity
Wait for the wireless network connection icon to appear at the top of the screen, then go back to the "Settings" menu.
Step 5. Turn on Airplane Mode, then turn it off
Find the "Airplane Use" entry. It is located at the top of the iPhone's "Settings" menu. After activating the "Use in aero" mode, wait a few seconds for the Wi-Fi connection indicator to disappear from the screen before deactivating it again. This will reset the network connection configuration settings and the device will be ready to flush DNS cache data.
If you are using an Android device, select the "More" option in the "Settings" menu to be able to activate and deactivate the "Airplane mode"
Step 6. Press and hold the key on the device you use to lock the screen, then slide the "slide to power off" slider to the right
The device will be turned off and, at the same time, the DNS service cache will be emptied. Wait at least 15 seconds after turning off the device.
If you are using an Android device, you will need to hold down the "Power" button and then choose the "Shut Down" option from the menu that will appear on the screen
Step 7. Turn your phone back on
Press and hold the key to lock the screen until the device starts up again.
Step 8. Verify that clearing the DNS cache data has paid off
Use your device's internet browser to visit problematic websites. At this point, you should be able to view its contents without any problem.
After flushing the DNS cache, the first loading of the web pages of the sites you visit will take longer than normal
Part 2 of 3: View DNS Cache Contents on PC
Step 1. Go to the "Start" menu, then click on "All apps"
If you are using older versions of the operating system, you will need to click on "All Programs" in the "Start" menu and choose the "Accessories" option
Step 2. Click on "Windows System"
Step 3. Click the "Command Prompt" icon with the right mouse button, then choose the "Run as administrator" option
A "Command Prompt" window will open with computer administrator access rights that will allow you to execute any type of command.
Step 4. Type the command "ipconfig / displaydns" omitting the quotes
Check carefully what you have written before pressing the Enter key to execute the command that will allow you to view the contents of the cache.
Step 5. Examine the contents of the DNS cache by scrolling through the "Command Prompt" window
Within the latter, the IP addresses of the websites you frequently visit will be listed. At this point, you can choose to clear the DNS cache.
The history of the websites you visit is stored in the cache of the DNS service and is independent of the browsing history of the browser. If you delete the data of the latter, the cache of the DNS service will not be altered
Step 6. Flush the DNS service cache using the "ipconfig / flushdns" command
Again omit the quotes. If an error message appears while browsing the web, clearing the DNS service cache should fix the problem. Also, this should speed up normal computer operation as the data in the cache will be up-to-date.
Step 7. Verify that clearing the DNS cache data has paid off
Use your PC's internet browser to visit problematic websites. At this point, you should be able to view its contents without any problem.
After flushing the DNS cache, the first loading of the web pages of the sites you visit will take longer than normal
Part 3 of 3: View DNS Cache Contents on Mac
Step 1. Open the "Spotlight" search bar
It features a magnifying glass icon and is located in the upper right corner of the screen.
Step 2. Search using the keyword "terminal", then launch the "Terminal" app
The "Terminal" window of the Mac operating system allows you to execute operating system commands such as the one that allows you to access the information contained in the DNS cache.
Step 3. Type the command "sudo discoveryutil udnscachestats" inside the "Terminal" window
Remember to omit the quotes. Press the Enter key to execute the command.
- The "sudo" parameter is used to be able to execute the command with the access privileges of the system administrator account that are necessary to be able to view sensitive information stored in the Mac.
- The "discoveryutil" parameter is used to request information about the DNS cache from the system.
- The "udnscachestats" parameter is used to view the first of the two sections that make up the DNS cache.
Step 4. Enter the password of the Mac administrator account
This is the password you normally use to log in. Press the Enter key to execute the command. The contents of the Unicast DNS cache should appear inside the "Terminal" window.
- The Unicast DNS cache (UDNS) has the task of converting the URLs of websites (for example www.facebook.com) into the corresponding IP address that the computer will use for future requests.
- The UDNS cache is intended to require only one IP address for a website server, regardless of the number of servers that exist. If for any reason the cached server no longer responds to requests, a DNS error will be generated.
Step 5. Examine the contents of the DNS cache by scrolling through the contents of the "Terminal" window
You can use the information displayed to trace the IP address of the websites you frequently visit. If a DNS client error appears, it is most likely the content of the UDNS cache.
You can use the UDNS cache to examine the most recent browsing history. To get a complete overview, you will also need to analyze the contents of the Multicast DNS cache
Step 6. Close and reopen the "Terminal" window
This step is to avoid receiving error messages when you go to examine the second section of the DNS cache.
Step 7. Type the command "sudo discoveryutil mdnscachestats" inside the "Terminal" window
Again omit the quotes. Press the Enter key to execute the command.
- The "sudo" parameter is used to be able to execute the command with the access privileges of the system administrator account that are necessary to be able to view sensitive information stored in the Mac.
- The "discoveryutil" parameter is used to request information about the DNS cache from the system.
- The "mdnscachestats" parameter is used to view the data of the Mac's Multicast DNS cache.
Step 8. Enter the password for the Mac administrator account
This is the password you normally use to log in. Press the Enter key to execute the command. Inside the "Terminal" window the contents of the Multicast DNS cache should appear.
- The Multicast DNS cache (MDNS) also has the task of converting the URLs of websites (for example www.facebook.com) into the corresponding IP address that the computer will use for future requests.
- Multicast cache is intended to store the IP addresses of multiple servers on a single website. In this case, if a server goes offline or no longer responds to requests, the computer will be able to contact the other servers that are still active. This means that you will not receive any error messages from the DNS cache (or you will receive far fewer) than if you were using a Unicast network.
Step 9. Examine the contents of the Multicast DNS cache by scrolling through the contents of the "Terminal" window
You can use the information displayed to trace the IP address of the websites you frequently visit.
You can use the MDNS cache to look at the most recent browsing history. To get a complete overview you will also need to analyze the contents of the Unicast DNS cache
Step 10. Empty the contents of the Mac's DNS cache
Type the command "sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder;" inside the "Terminal" window. Press the Enter key to execute the command. All data stored in the Mac's DNS cache will be cleared. This will allow you to resolve any problems related to errors generated by the DNS server. The command shown is for the latest version of the Mac operating system.
- The command indicated flushes both DNS caches (UDNS and MDNS). By doing this, you should fix any browsing issues related to your Mac's DNS cache and prevent it from happening again in the future. Clearing DNS cache data does not harm your Mac in any way.
- The commands in the "Terminal" window to flush the DNS cache vary depending on the version of the operating system being used. To find out which version of the operating system you are using, go to the "Apple" menu and click on the "About this Mac" option.
- OS X 10.10.4 and later - use the command "sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder;";
- OS X 10.10 up to 10.10.3 - use the command "sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches;";
- OS X 10.7 up to 10.9 - use the command "sudo killall -HUP mDNSResponder";
- OS X 10.5 up to version 10.6 - use the command "sudo dscacheutil -flushcache";
- OS X 10.3 up to 10.4 - use the "lookupd -flushcache" command.
Step 11. Verify that clearing the DNS cache data has paid off
Use your preferred Mac internet browser to visit problematic websites. At this point, you should be able to view its contents without any difficulty.
After flushing the DNS cache, the first loading of the web pages of the sites you visit will take longer than normal
Advice
To clear the cache of the DNS service on tablets and smartphones, activate and deactivate the "Use in airplane" mode and then restart the device
Warnings
- Before using the "Command Prompt" or "Terminal" window to execute potentially dangerous commands, you should always back up your computer. Also, before executing a command, always check carefully that you have entered it correctly.
- If you are using a computer shared with other users or in the workplace, avoid viewing the contents of the DNS cache or clearing its data. In this case, it is always best to ask for permission first.