Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force Firefox to reset its DNS cache on-demand?

Tags:

firefox

dns

I use hostnames to temporarily redirect certain hostnames to localhost when coding.

Problem is Firefox caches DNS entries for much longer than I would expect (network.dnsCacheExpiration has no effect).

How can I force Firefox to reset its DNS cache on-demand?

like image 452
sunknudsen Avatar asked Jan 27 '20 13:01

sunknudsen


People also ask

How do I force DNS cache to clear?

Open the Start Menu and start typing command prompt until you see it in the results. 2. Type ipconfig /flushdns when the prompt loads and hit Enter on the keyboard. The DNS Cache database on your computer is now clear.

Does Firefox have a DNS cache?

Firefox is an Internet browser which integrates a DNS cache feature. This feature automatically saves the DNS settings of websites that you frequently visit. DNS settings are records that contain a website's domain name and its corresponding Internet Protocol address.

How often is DNS cache cleared?

3 Answers. Show activity on this post. The DNS cache doesn't ever flush, unless you explicitly tell it to or you make a DNS/networking related configuration change. DNS records have a Time To Live (TTL) value associated with them which tells a DNS cache how long the particular record is good for.


Video Answer


3 Answers

The accepted answer doesn't work for me. It clears cached pages, but not dns entries.

Instead, I go to this URL: about:networking#dns, then click the Clear DNS Cache button.

I'm afraid I don't recall where I learned about that, but the existence of that button pretty clearly indicates that Mozilla intends it to be how you do this.

WHY THIS MATTERS: I sometimes modify my hosts file (Windows), then flush DNS in the OS (admin cmd prompt, ipconfig /flushdns. That typically works the first time I do it, but when I remove a host file entry to go back to the real address, Firefox doesn't pick it up without this.

like image 143
enigment Avatar answered Oct 08 '22 03:10

enigment


According to this thread on mozilla support by jscher2000:

"Clearing the cache is supposed to clear both pages and DNS entries.

Another way to flush the DNS cache might be to set it to a very small number of records:

(1) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button promising to be careful or accepting the risk.

(2) In the search box above the list, type or paste dns and pause while the list is filtered

(3) Double-click the network.dnsCacheEntries preference and enter a low value such as 5 and click OK

(4) Leave network.dnsCacheExpiration and network.dnsCacheExpirationGracePeriod with their default values (you can right-click > Reset if needed)"

also,

You can remove all data stored in Firefox from a specific domain via "Forget About This Site" in the right-click context menu of an history entry ("History -> Show All History" or "View -> Sidebar -> History").

like image 42
Onyrew Avatar answered Oct 08 '22 03:10

Onyrew


Found the issue (will submit a bug report to Firefox).

When Enable DNS over HTTPS is enabled, Firefox ignores entries in /etc/hosts.

Great security feature to enforce DNS over HTTPS, but I believe localhost should still resolve locally.

Bug report submitted.

like image 1
sunknudsen Avatar answered Oct 08 '22 02:10

sunknudsen