« Dung Fly | Main | Moth »
Friday
Jun032011

Firefox ignoring /etc/hosts when DNS not available

I have a laptop running a development LAMP web server under Ubuntu 10.04 LTS.  The laptop is normally connected to a small network where the DNS name server is a modem-router with IP address 10.0.0.2.  The relevant parts of the network configuration files are as follows:

 /etc/resolv.conf:
nameserver 10.0.0.2
...

/etc/hosts:
127.0.0.1 localhost laptop site.laptop
...

/etc/nsswitch.conf:
...
hosts files mdns4_minimal [NOTFOUND=return] dns mdns4
...

/etc/host.conf:
order hosts, bind
...

This all works as expected if the laptop is connected to the network and the DNS name server is available:  I can ping site.laptop and can also visit the site.laptop website in Firefox 3.6.17.  However, when I disconnect the laptop from the network and the DNS server is no longer available I can still ping site.laptop but in Firefox I get "Server not found" whenever I try to visit site.laptop.

I tried all sorts of things in my attempts to fix this problem, and learned a lot about DNS in the process, but nothing worked.  And then I remembered that a while back I had disabled IPv6 DNS in Firefox to fix a bug which was delaying page loads.  I reasoned that the bug that caused the delay might well have been fixed by now, so I entered about:config in the Firefox URL bar and then set network.dns.disableIPv6 back to its default value of false.

This fixed my "Server not found" problem: I can now get to site.laptop in Firefox with or without the DNS name server available; and the slow page load problem has not returned.

Reader Comments (4)

Geat! Your post solved my identical problem! I submitted a question at superuser.com and someone answered with the link to this post. Thank you very much!
2011-06-14 | Unregistered CommenterCarlo
thank u so much!
i was staring at this problem for a few hours!
2011-10-20 | Unregistered Commenteraaron
Thanks so much, I was puzzling over this! It's particularly frustrating if you are using /etc/hosts so that you can, for example, make a local mirror of a site for a demo where you might not have internet connection.
2014-04-19 | Unregistered CommenterLuke Plant
Thank you so much for this information. I have been scanning the Firefox about:config list for a long time trying to figure out what to change after an embarassing off-network demo. Chrome worked with the local web server, but Firefox didn't. In my case the IPV6 was disabled by default, though (ie flag set true). Any idea why this stops use of the hosts file?
2014-12-11 | Unregistered Commenteralgernon

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.