54

I was too quick about visiting a site I set up on a customer server, and Firefox now remembers, that the default site for (example)

testsite.mycompanyname.com (non existing subdomain, same as *.mycompanyname.com)

is

www.mycompanyname.dk - or rather the IP of the default server

I have then later set up the public DNS (a-record) to redirect to another server, but Firefox remembers the default IP adress.

Chrome/IE/Safari - no problem, as they have not visited that site before DNS kicked in...

I have set these in about:config:

network.dns.disablePrefetch = true
network.dnsCacheExpiration = 0

Anything else?

I really need firebug to debug the frontend on that site....

Cheers

meager
  • 209,754
  • 38
  • 307
  • 315
Steen
  • 2,503
  • 2
  • 17
  • 31
  • Ahhh.... stupid me.... did try that, but ticked everything off but the websitespecific settings, as I wanted to keep cookies/history for everything else......did not notice the cache one. All clear now. Add answer if you want accept of answer – Steen Oct 25 '12 at 07:25
  • If you've edited the DNS settings locally and the result in the browser doesn't correspond to the result from nslookup, make sure that you've changed the DNS settings in the right place. In my case, I was connected to the Internet through a PPPoE connection, the wireless router was in bridge mode, I've set the DNS servers in the wireless connection settings, nslookup started to use new servers, but the browser ignored them and continued to use the DNS from the ISP until I changed the DNS servers in the PPPoE connection settings. – user May 29 '17 at 09:23
  • btw, Firefox doesn't cache DNS resolutions to disk, and there's a menu to inspect the in-memory cache: https://support.mozilla.org/en-US/questions/1258756 – Xerus Dec 25 '20 at 18:16

5 Answers5

75

DNS caching occurs at multiple levels: Application asks local system, which asks locally configured resolving DNS server, which asks authoritative DNS servers.

Caching by Application varies.

  • I've found for Firefox that quitting and restarting works. The relevant settings in about:config are network.dnsCacheEntries and network.dnsCacheExpiration, which can be set to 0 in order to disable caching.

Caching by local system is typically 1 hour.

  • Diagnostic: ping, like other applications, uses local system DNS cache
  • Flush MacOsX 10.8: sudo killall -HUP mDNSResponder (reference)
    (May vary for other versions)
  • Flush Windows: ipconfig /flushdns (only if the DNS caching service, HKLM\SYSTEM\CurrentControlSet\Services\Dnscache, is enabled; check with net start|findstr /i dns or compmgmt.msc)
  • Linux/Unix may use nscd (name services caching daemon), or dnsmasq, or both ...

Caching by local resolving DNS server may run to several days, depending on TTL associated with DNS record.

  • Diagnostic: nslookup first reports address of resolving server, then address requested.
  • Flush BIND: rndc flush or rndc flushname DOMAIN.NAME

TTL stands for "time to live" a term used to describe how long a DNS record is to be deemed valid by the requesting client or server. A short TTL means that the requester is told not to cache a DNS lookup for too long. The TTL can range from mere seconds (e.g. for DynDNS and similar) to days or weeks.

Ian Dunn
  • 3,146
  • 5
  • 24
  • 39
DL-van
  • 766
  • 6
  • 2
  • 2
    Just closing and opening Firefox helped for me, thanks – jaywink Jun 01 '14 at 21:33
  • 1
    @jaywink: not useful. Sure it may help, but if *that's* the cure, I'd rather move on to another browser. – 0xC0000022L Jul 13 '15 at 10:23
  • As of at least Firefox Quantum 69.0, there is now an option to use DNS over HTTPS. If this is enabled, it will override any cache flushing you do on your system, any cache flushing you do in Firefox, & any settings you change in about:config. Option > General > Network Settings > Enable DNS over HTTPS. – Henry Clayton Sep 13 '19 at 14:13
24

I've been using the "Clear Recent History\cache" solution for a while now, but I've noticed that it stopped working after one of firefox updates (probably 20.0.1). Because of that I've switched to https://addons.mozilla.org/en-US/firefox/addon/dns-cache/ add-on to do the DNS clearing. I hope this will help someone with the same problem.

Edit: Changed the url as suggested by Haozhun.

Edit2: Unfortunately as of FireFox 32, this plugin is no longer compatible and cannot be used. Possibly https://addons.mozilla.org/en-US/firefox/addon/dns-flusher/ might be able to replace it.

jahu
  • 4,899
  • 2
  • 35
  • 55
  • I've also tried “Clear Recent History” → “☑ Cache”, and I can confirm that Firefox 20.0 fails to actually respond with regard to DNS. I flush all caches along the way (refresh [OpenDNS CacheCheck](http://www.opendns.com/support/cache/?d=hexiano.org), restart `dnsmasq` on my OpenWrt router), and I know for sure that the correct DNS resolution has propagated all the way to the last hop, because `dig [hostname]` returns the correct answer. I'm pretty sure it used to work, so maybe it's a regression, or just another ‘good idea’ from Mozilla. Either way – one should not need an addon to flush DNS. – James Haigh Jun 28 '13 at 00:18
  • P.s. Thanks for finding the addon, but I do hope that there is a built-in way of flushing the DNS cache in Firefox 20.0 and above. – James Haigh Jun 28 '13 at 00:24
  • 2
    Thank you for sharing an up-to-date solution. Can you please substitute `pl` with `en-US` in the url you provided? I believe such a modification would be helpful. – Haozhun Jun 30 '13 at 05:22
  • Clearing just "cache" flushed DNS for me, so this may be the best solution again. Of course, we're on version 42 now. – Jeff Davis Nov 03 '15 at 16:11
  • 1
    DNS Flusher is not compatible w/ Firefox Quantum – Ian Dunn Feb 15 '18 at 19:05
  • @IanDunn That's unfortunate, but the answer was written/edited back in 2013/2014. – jahu Feb 22 '18 at 11:29
  • I realize that, but that only means that [it should be edited](https://meta.stackexchange.com/a/11706/165480) so that it's correct *now* (which is what matters the most), or deleted, rather than leaving it here to lead people astray. I'll go ahead and submit an edit. – Ian Dunn Feb 22 '18 at 17:19
6

Install the addon DNS Flusher, which works for me.

user3477065
  • 69
  • 1
  • 1
  • 1
    @user1981275 Actually it does provide a work around for the problem mentioned in the question, so I see no reason to delete it. – Mike Mar 30 '14 at 02:08
  • 1
    It's a little ridiculous that we have to install an Add-On just to flush the DNS cache.. The clear cache function should do that.. :( – JamesTheAwesomeDude Mar 28 '15 at 15:45
  • @JamesTheAwesomeDude: disable the FF-internal DNS cache by setting `network.dnsCacheExpiration=0` ... I am unsure whether this helps with my issue, but so far I didn't encounter it again. – 0xC0000022L Jun 23 '15 at 17:35
6

I found that network.dnsCacheExpiration = 0 alone did not quite do the trick, but if you also set network.dnsCacheEntries = 0 then the DNS cache gets disabled for good. So:

network.dnsCacheEntries = 0
network.dnsCacheExpiration = 0
Roman Starkov
  • 52,420
  • 33
  • 225
  • 300
5

The following methods, which worked at some point, do not work presently (doing all of them doesn't work):

  • Restarting the browser
  • Clearing the browser cache
  • Setting network.dnsCacheExpiration=0
  • ipconfig /flushdns

However, you can open a new private window, private windows evidently don't use the same DNS cache as the regular windows (which is comforting).

Vladimir Kornea
  • 3,434
  • 2
  • 34
  • 37