How do I flush my Pi-hole cache?

Why Do We Need Cache?

Cache plays an important role with Pi-hole. This is part of the reason Pi-hole can make your network perform faster. Once a queried domain name has been cached, future replies for that same domain name will be much faster since Pi-hole already knows about it.

Problems When White Or Black Listing

However, you can run into issues if you decide to white or blacklist a domain that is already cached. For example, if you saw ads on a site and decided to blacklist wsp.mgid.com, you may not immediately see the ads disappear. This is most often due to caching.

Since Pi-hole already responded to a query for wsp.mgid.com, it doesn't know that this domain should be blocked until you flush the cache--even though it exists on the blacklist. Pi-hole won't know about this change until the cache is flushed (or the cache expires, which is defaulted to 300 seconds).

Flushing The Cache

But running

pihole restartdns

will flush the cache and allow a newly-blacklisted (or whitelisted) domain to be answered correctly (see below).

More Complexity

You may find that running that command still does not make whatever site you are visiting to display properly. This is because cache exists in several other places:

  • your browser may cache content
  • your operating system may cache DNS queries
  • other apps or systems used to access your domain may use cache along the way

because of this, you may need to flush cache in one or more of the above places before you see an effect (in addition to restarting Pi-hole's DNS server).

7 Likes

for windows to permanently disable the DNS caching service use these steps

  1. Click the start button.
  2. Type services.msc in the search box.
  3. Click on services.msc in the search results.
  4. Scroll down until you see "DNS Client" in the "Name" column.
  5. Double click on "DNS Client."
  6. Click the Stop button.
  7. To re-enable DNS caching, you can click the Start button found by repeating steps 1-5.

to Easily view and clear the chrome DNS Cache go to this address in chrome chrome://net-internals/#dns

3 Likes

A question on flushing the DNS cache, dealing with a Whitelist issue. If temporarily halting Pi-Hole causes the expected behavior and resuming Pi-Hole causes the whitelist entry to again be ignored, does that point away from an issue with the browser or device/OS cache?

Well if you’re having issues in 3.3, look here:

Otherwise, I would say it could be either one or a combination of both.

Any idea why the stop and run buttons are greyed-out and cannot be "clicked" for this service?
Other services have the start/stop options.

I have tried to run services.msc as admin and the usual window to allow didn't appear, it started normal. Windows 10 here.

A post was split to a new topic: How to flush DNS cache Windows 10

I would love to see a web interface to reset the DNS cache. I don't suppose there is a plugin for that?

Jusr restart the resolver (via Settings > System), it will flush the cache as well.

had problems with flushing but

sudo pihole restartdns reload

did the trick