[SOLVED] Firefox doesn't seem to be using /etc/hosts
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have an /etc/hosts file with different domains mapped to 127.0.0.1. Now when I'm not connected to the internet and try to access that domain name, Firefox says 'server not found' even though going to 127.0.0.1 works fine. If I am connected to the internet then all of a sudden going to that domain name works.
My best guess is that when there's no internet connection Firefox goes into some kind of offline mode which doesn't allow it to connect to anything except localhost or 127.0.0.1. Any attempts to access a name, even if that name is mapped in /etc/hosts and should be respected, never occur and the result is 'server not found'. Is there some way to get Firefox to first try /etc/hosts even when in this 'offline mode'?
Could we be allowed to know your distribution?
How about your version of FIREFOX, and if it is the MOZILLA distribution or the one form your LINUX repos?
What do you find in your hosts.conf file?
Can you provide all or a portion of your hosts file?
Could we take a look at your resolv.conf file?
I have an /etc/hosts file with different domains mapped to 127.0.0.1. Now when I'm not connected to the internet and try to access that domain name, Firefox says 'server not found' even though going to 127.0.0.1 works fine.
Unless you are running a server on localhost, this would be normal behavior when you try to connect to any website. Firefox cannot reach the DNS server, so it can't load any page by domain name.
Generally, the point of mapping valid domains (such as doubleclick dot com) to localhost is so the web browser cannot go to them when the internet connection is active. It functions as sort of a blacklist in this usage.
In my case, I get holes in the webpage where the ads are supposed to be. Which is just hunky-dory with me.
This site has an excellent description of how hosts files work in relation to internet browsing.
What would be abnormal would be Firefox's actually loading ads from doubleclick dot com or any internet address redirected to 127.0.0.1 in /etc/hosts when the internet connection is active.
Is Firefox actually going to the websites listed in your hosts file or are normal websites loading minus content provided by the blacklisted addresses?
Firefox cannot reach the DNS server, so it can't load any page by domain name.
...
Is Firefox actually going to the websites listed in your hosts file or are normal websites loading minus content provided by the blacklisted addresses?
Yes Firefox should be actually going to the website listed in my host file, I'm not using it as a blacklist.
Though Firefox can't reach the DNS server, I was under the impression that anything resolving host names FIRST goes to the hosts file and only if it's not there it goes to the DNS server. (Isn't that the whole point?) If my internet connection is down, Firefox could still first go to the host file and complete my request rather than giving up altogether. So I'm hoping there's a way to make it behave like this.
I was under the impression that anything resolving host names FIRST goes to the hosts file and only if it's not there it goes to the DNS server. (Isn't that the whole point?) If my internet connection is down, Firefox could still first go to the host file and complete my request rather than giving up altogether. So I'm hoping there's a way to make it behave like this.
The sequence in which the resolver library attempts to perform host lookups is controlled by the /etc/host.conf file. Mine looks like this:
Code:
multi on
order hosts,bind
which causes the /etc/hosts file to be checked first, followed by a name server lookup if nothing matches in the hosts file. You should have a manpage for hosts.conf that explains the details.
Syntax errors in /etc/hosts can also cause lookups there to fail.
In your original post, if I understand it correctly, you said that
Quote:
Originally Posted by veeruk101
I have an /etc/hosts file with different domains mapped to 127.0.0.1. Now when I'm not connected to the internet and try to access that domain name, Firefox says 'server not found' even though going to 127.0.0.1 works fine. If I am connected to the internet then all of a sudden going to that domain name works.
I'm a little puzzled.
I would expect that, if you are not connected to the internet, no internet site would be accessible.
Maybe I'm misunderstanding what you were expressing when you wrote, "not connected to the internet."
I interpreted it to mean that the ethernet cable was removed or the equivalent thereof.
Is the site you're trying to hit a local server on your local network?
My /etc/host.conf file had only 'multi on', so I added 'order hosts,bind' but that changed nothing.
Quote:
I would expect that, if you are not connected to the internet, no internet site would be accessible.
Maybe I'm misunderstanding what you were expressing when you wrote, "not connected to the internet."
I interpreted it to mean that the ethernet cable was removed or the equivalent thereof.
Is the site you're trying to hit a local server on your local network?
I'm trying to hit a local server on my local network. So when I type 'testdomain.com' into Firefox, if that is mapped to 127.0.0.1 in /etc/hosts, I would expect Firefox to access localhost even if it's not connected to the internet. Maybe there's some Firefox setting for this? I'm really confused here. (Also, there aren't any syntax errors in my /etc/hosts because everything works fine when my internet is connected.)
I found the following blog post which describes an identical problem (http://tristram.squarespace.com/home...available.html), but his fix didn't work for me. I had previously changed network.dns.disableIPv6 in about:config to be true, but then when I tried his suggestion of changing it back to the default of false it didn't work for me...
Could it have something to do with /etc/nsswitch.conf maybe? There are several lines in that file but the one that seems to be related is 'hosts: files dns'.
1. if your networking is down on a machine, then even localhost access may be disabled.
2. are you running a DNS server (perhaps using dnsmasq) on your local network?
3. how does your machine running Firefox pick up and IP address (static or dhcp)?
When your external access goes away, you lose access to the google nameservers, and all name resolution will fail. Entries in the hosts file CAN resolve names, but things get a little picky. Also, if your networking checks BIND before HOSTS it will have to time out on all listed nameservers before connecting, and some software times out faster.
It strikes me that you have been referring to what Firefox uses, when what is really at question is your TCPIP networking and addressing. Firefox just happens to be the application in which you have observed the behavior.
I have cable internet access, and it has been pretty reliable. When it does go down, my access to services in my local network remains unaffected. I run my own dns and dhcp server, local WIFI, music streamer, and network storage using Debian. Under these conditions I have never seen behavior such as you describe.
I'm trying to hit a local server on my local network. So when I type 'testdomain.com' into Firefox, if that is mapped to 127.0.0.1 in /etc/hosts, I would expect Firefox to access localhost even if it's not connected to the internet.
Only if the server application is running on the computer as Firefox. "127.0.0.1" means "there here computer," not "this here network."
If your ip address was 192.168.1.103 and the server application is running on 192.168.1.13, /etc/hosts would have to point to 192.168.1.13.
In the initial post, the OP indicated that going to the numeric address 127.0.0.1 worked, but using the name "localhost" resulted in "Server not found."
Thanks everyone for helping me through with this. It turns out that this was in fact a bug. With yesterday's release of Firefox 8.0, they also solved this issue!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.