+5 votes
277 views
How to reset the DNS cache in macOS Mojave

in Mac by (551k points)
reopened | 277 views

1 Answer

+3 votes
Best answer

1. Clear the DNS cache using the macOS Mojave terminal
2. Check response times with the DIG command in macOS Mojave

One of the most vital and used network, actually used every time we access the network, is the DNS (Domain Name System) which fulfills the simple task of translating domain names that we use frequently, that is, its mission is to allow us to remember a URL like www.solvetic.com, but not the IP address 178.33.118.246 which is the IP of the server where TechnoWikis is hosted, it would be very complex for us as users to remember hundreds of IP addresses of each site so that DNS does this task for us.
Each device in the network has an IP address which is unique to that computer, similar to our identification document, and this IP address is made up of four integers from 0 to 255, separated by dots, for example 192.168. 0.19 and each server on the Internet has the same IP address (Static), which is why when we access a browser we enter the domain name but not the IP address and this is achieved thanks to the DNS cache..

To learn more about the context and functionality of the DNS cache , we will understand how it works, first, when we enter the domain name in the browser, our team asks the local DNS server about the IP address of the computer where it is located. Hosted that page that we are going to visit, remember that the DNS server has a large database where millions of translations of domain names to IP addresses are hosted so that the search process is much more effective.

The DNS server database is distributed and shared with other providers both local and network on their respective DNS servers, so if the domain name that we have entered in the browser is not in the local DNS, it is responsible for carrying Make a request to other DNS of the network until the appropriate translation is found for the website to be accessed. So the databases of the DNS servers cache these domain name to IP translations for some time, this is one of the reasons why, sometimes, when a website changes servers, it will not be possible access it, since at the time of consular the DNS server redirects them to the previous IP address but not to the new one..

Locally, our team stores a DNS cache, so when a website is visited, the team will no longer carry out the process of consulting the DNS server about the IP address of that site, but instead It will automatically direct to the one stored in its database.
So one of the most normal support and administration tasks is to clear the DNS cache when errors such as:

  • Failures when accessing a website
  • Communication errors
  • Slow access requests to a specific website
Now TechnoWikis will explain how we can clear the DNS cache in macOS Mojave completely.

1. Clear the DNS cache using the macOS Mojave terminal

Step 1

To access the macOS Mojave terminal we have one of the following options:
  • Access from the Go / Utilities / Terminal route.
  • Use the following key combination and select Terminal there.

+ ⌘ + U ⇧ + ⌘ + U

  • Enter the word terminal in Spotlight and there select the respective utility.
Step 2

In the terminal console, we will execute the following line:
 sudo dscachéutil -flushcaché; sudo killall -HUP mDNSResponder 
Step 3

Press Enter, enter our password and the process will be carried out automatically: image
Step 4

In case this command is not executed correctly and generates an error, it will be possible to use the following command alternatively:
 sudo killall -HUP mDNSResponder; sudo killall mDNSResponderHelper; sudo dscachéutil -flushcaché; say MacOS DNS cache has been cleared 

2. Check response times with the DIG command in macOS Mojave

Step 1

One of the advantages of cleaning the DNS cache in macOS Mojave is that the response times between the local computer and the remote website are undoubtedly improved, to verify this we will use the command dig (domain information groper) which is a tool designed to query DNS servers to request information on details such as:
  • Host addresses
  • Mail exchangers
  • Name servers and much more.
Step 2

For this check we will use the following syntax:
 dig (website) 
image
Step 3

As we see data is generated as. Based on the response times generated by the dig command, it will be possible to determine if the DNS works in the correct way or if on the contrary it will be necessary to perform a specific task on it.
  • Number of queries sent
  • Errors returned
  • CNAME used
  • Total query time in milliseconds
  • Server IP
  • Date and time of consultation
It's that simple we have cleared the DNS cache in macOS Mojave to improve frequent access to websites.

by (3.5m points)
edited

Related questions

+5 votes
1 answer
asked Oct 9, 2019 in Mac by backtothefuture (551k points) | 240 views
+4 votes
1 answer
asked Oct 13, 2019 in Mac by backtothefuture (551k points) | 238 views
+4 votes
1 answer
asked Oct 11, 2019 in Mac by backtothefuture (551k points) | 228 views
+4 votes
1 answer
asked Oct 11, 2019 in Mac by backtothefuture (551k points) | 203 views
+3 votes
1 answer
asked Oct 11, 2019 in Mac by backtothefuture (551k points) | 233 views
Sponsored articles cost $40 per post. You can contact us via Feedback
10,644 questions
10,776 answers
510 comments
3 users