How to Flush the DNS Cache on Linux
As a Linux user, you may occasionally encounter problems with your DNS (Domain Name System). These issues can range from slow website loading times to complete failure to access certain sites. One effective solution to such problems is to clear your DNS cache.
Flushing your DNS cache helps to clear any outdated entries that might be stored in the cache, allowing your system to retrieve fresh DNS records from the servers. Here’s a step-by-step guide on how to flush the DNS cache on Linux.
Step 1: Open the terminal
To access the terminal in Linux, press the Ctrl + Alt + T key combination. Alternatively, you can use the search function to locate the terminal.
Step 2: Stop DNS caching service
You will need to stop the DNS caching service before proceeding. To stop the service, enter the following command into the terminal:
sudo systemctl stop systemd-resolved.service
This command brings up a prompt for the root user password. Enter the password and continue.
Step 3: Clear the DNS cache
Having stopped the DNS caching service, it’s time to clear the cache. Enter the command below to clear the DNS cache:
sudo systemd-resolve –flush-caches
This command empties the DNS cache and allows you to start accessing fresh DNS records.
Step 4: Restart DNS caching service
For your system to operate efficiently, you must restart the DNS caching service.
The command below is used to start the DNS caching service:
sudo systemctl start systemd-resolved.service
This command starts the DNS caching service, and your system is now ready to retrieve fresh DNS records.
In conclusion, flushing the DNS cache on Linux is a straightforward process that can help resolve several DNS-related issues. Follow the above steps to help your system retrieve fresh DNS records and improve your browsing experience.