Clear DNS cache in Firefox
During the day I switch my VPN connection on and off several times. When I try to hit a server inside my company’s network while the VPN connection is down, it obviously fails and because I’m using OpenDNS every hostname resolves to an ip-address (in this case an ip-address of a server at OpenDNS). I connect to VPN and then reload the page in Firefox and the same error page shows up. The reason for this behavior is Firefox’s internal DNS cache. The only remedy at that point is to close Firefox and restart it, which clears the in-memory DNS cache.
However, there’s a solution that does not require a restart.
- type
about:config
in Firefox’s address bar - acknowledge the warning that appears next
- find an entry called
network.dnsCacheExpiration
and set it’s value to 0 - if there’s no such entry, create a new integer item with the name above and a value of 0
- now go back and change the value to 3600
In step 3 (or 4) we tell Firefox that the expiration time for DNS cache is 0 seconds, which means that cache entries expire immediately, essentially clearing the existing cache. In step 5 we go back to the standard 3600 seconds (1 hr) cache expiration. The net effect of these steps is an empty DNS cache, meaning that the next time you hit the trouble server above, Firefox will attempt to resolve the hostname to an ip-address.
July 22nd, 2010 at 8:36 am
Worked like a charm. Can I delete the entry though, instead of setting it to 1 hour? Because I think a nonexistent entry will prevent the cache from clearing itself ever again automatically. That is usually a favourable setting, as few pages ever move. What do you think?
July 22nd, 2010 at 8:42 am
I have no idea, Lorne. Just give it a try and if it doesn’t work, restore the entry.
–Tobias
December 16th, 2011 at 2:32 pm
[…] to clear DNS caches in Firefox and Chrome but with no luck, here’s what I did in Firefox: http://www.kahunaburger.com/2009/03/18/clear-dns-cache-in-firefox/ And for Chrome I found “chrome://net-internals/#dns” and clicked the clear DNS […]
January 16th, 2012 at 7:13 pm
[…] to clear DNS caches in Firefox and Chrome but with no luck, here’s what I did in Firefox: http://www.kahunaburger.com/2009/03/18/clear-dns-cache-in-firefox/ And for Chrome I found “chrome://net-internals/#dns” and clicked the clear DNS […]
January 25th, 2012 at 7:18 am
[…] obvious DNS caches in Firefox and Chrome but without any luck, here’s what I do in Firefox: http://www.kahunaburger.com/2009/03/18/clear-dns-cache-in-firefox/ And for Chrome I found out “chrome://net-internals/#dns” and clicked the obvious DNS […]
December 19th, 2012 at 9:09 pm
Thanks for posting this. This also works great for thunderbird. I just added the setting and left it at 0, and switching between being on a VPN and being off a VPN is now seamless. Thunderbird does so few DNS lookups that I don’t think thunderbirds internal cache does much. The system dns cache should be more than enough.
February 13th, 2013 at 3:32 pm
“Clear DNS cache in Firefox | kahunaburger” genuinely got myself addicted
on your website! Iwill certainly wind up being back again more regularly.
Thanks a lot ,Richelle
July 14th, 2013 at 1:13 pm
Default for network.dnsCacheExpiration is 60, not 3600. This number does represent seconds, however.
http://kb.mozillazine.org/Network.dnsCacheExpiration
August 18th, 2013 at 10:44 am
[…] Firefox 清除 DNS Cache 的步驟如下述: (下述翻譯摘錄自此篇: Clear DNS cache in Firefox) […]
November 17th, 2014 at 10:22 am
great post worked well. Thx
February 27th, 2015 at 5:48 am
Thanks for the tips, I tried them due to a problem with Superfish adware continuously trying to access their website. I guessed maybe the DNScache had been modified to jump there, but in fact that was NOT the case. (Actually some plugin has been modified, and now -after deactivating all- I need to find _which_ one).
September 28th, 2015 at 10:53 am
Thank you!
February 4th, 2016 at 10:16 am
With the current FF (44) on OS-X this does not work any more 🙁
I must restart FF to make it work!
November 29th, 2016 at 10:39 am
This doesn’t work. Even after restarting firefox (50), it’s still caching the old invalid entries.
February 28th, 2017 at 12:38 am
how you can help
Clear DNS cache in Firefox | kahunaburger