I am developing a website on localhost with the following entry in my hosts file:  mysite.local

That IP is coming from a Vagrant provisioned VM hosted in Virtualbox.

Whenever I try to load the site in Firefox, it takes about 3-4 seconds before it is able to resolve the domain. I see looking up mysite.local in the lower left of Firefox for a while, then it loads the site quickly. Each subsequent lookup happens quickly as if it has cached that DNS lookup,

However, if I let the site go idle for about 5 minutes, the lookup is slow again.

Chrome and Safari do not have this problem. They both always resolve the domain quickly, even from a cold start. Firefox is the only one that struggles with it.

What can I do to troubleshoot what might be causing this problem in Firefox?

EDIT: It looks like Firefox caches DNS lookups for 60 seconds (according to about:config, which explains why the site is resolved quickly if I continually use it, but goes back to being slow if I let it sit idle. So the question then becomes, why is only Firefox having trouble resolving it when it's not cached?

  • What is the response time of you open the Terminal and run ping mysite.local or even curl -I mysite.local? Also, what is the web server you are using on your VM? Apache? Nginx? Something else? – JakeGould 2 days ago
  • Response time for ping mysite.local is 0.3 seconds on average. Nginx is the webserver. – AgmLauncher 2 days ago
  • 1
    Do you have DNS over HTTPS enabled? Go to about:preferences and check the Network Settings at the bottom of General. Or go to about:config and check network.trr.mode. – Bob 2 days ago
  • @Bob No, it is disabled (I didn't set this, it was just that way when I checked the settings). Enabling it fixed the problem though! What are the security ramifications of enabling DNS over HTTPs? – AgmLauncher 2 days ago
  • 1
    @Bob I took your advice, and Firefox doesn't like .local as a domain. I used .qwerty and it worked fine. I created several dummy sites on that VM, some with .local and some with .qwerty and all of the .local domains were slow, while .qwerty was fast. .com would not work (it always tried to resolve actual internet domains for them). I used to use .dev, but Chrome killed that so I switched to .local, which Firefox hates. Sigh. Thanks for the help though. The resolution is to change the TLD to something FF friendly. If you want to create an answer for your comment, I'll accept. – AgmLauncher 2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.