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:configin Firefox’s address bar - acknowledge the warning that appears next
- find an entry called
network.dnsCacheExpirationand 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 [...]