I have added these lines to the hosts file: localhost adobe.com adobe.com

It works perfectly on windows. But in Ubuntu 11.10 when I try to access it using Firefox the website is opening.

Google chrome though supporting /etc/hosts configuration. Google chrome is displaying:

"It works! This is the default web page for this server. The web server software is running but no content has been added, yet."


I can confirm your problem that it appears to affect, between both, Chrome and Firefox, only Firefox. This is an answer for users that are affected by the same problem and if they are affected by both/all browsers. Follow this steps to have this working correctly. Assuming you already edited /etc/hosts file to which I recommend the following 2 ways to edit the file:

  • Gedit - gksudo gedit /etc/hosts (You now have a GUI friendly way of editing the file. gksu which provides gksudo is discontinued in the official 18.04 and later repositories.)
  • nano - sudo nano /etc/hosts (You now have a terminal friendly way of editing the file.)

And you have for example: localhost adobe.com

or localhost adobe.com

(Both are the same thing.)

You first test this out to see if it is working correctly from the terminal. Type ping adobe.com and it should respond from the IP assign to it. In this case it should respond with That means it is OK.

Then we continue with the browser tests. You tested Chrome and it worked. You changed /etc/hosts between having and not having the entry for adobe.com and it worked every time you changed it. But then you went with Firefox, it might have worked the first time, but after changing hosts file back and forth it somehow stop working. This means it is a cache problem or a problem resolving the correct name.

In the case of Firefox and resolving the name, Firefox adds the the prefix www to the adobe website so it looks like this "www.adobe.com" but on Chrome it looks like this "adobe.com". They both point to the same place and the www prefix is just there to tell you that the place you are visiting is a web service. But in the case of your problem you would need to add that to the hosts file so when Firefox adds the prefix www it works. So it would look like this: localhost adobe.com www.adobe.com

OR just the same localhost adobe.com www.adobe.com

NOTE: Remember that you HAVE TO press F5 to refresh the site/Firefox tab or close the tab and open it again to test. Somehow pressing Enter like crazy won't do.

This should solve the problem for some users, but assuming up to now you still have not yet solved the problem, we can test out what could it be.

We got here a couple of levels of cache to check then. You got your program Cache, in this case Firefox, then you have your System Cache, in this case Ubuntu, and then you have your hardware cache, in this case your router.

For what I know, the Ubuntu Desktop version does not have a DNS cache service installed by default. The most commonly known is nscd and if you had that installed a simple /etc/init.d/nscd restart will do. But for most people they will not have this installed, so we can overrule the Ubuntu system's fault.

That leaves the router and web browser. In the case of the router you would have to configure it to stop DNS cache or reconfigure it to solve this issue. This totally depends on the Router model, manufacturer, etc. Not all routers do DNS cache, but some do and you would need to see in the configuration of it, if it has this option and if the option is enabled. But let us assume you do not have a DNS Caching enabled router.

This leaves the browser.

To find out if Firefox is being bad with DNS Cache you can install an Add-on to check DNS Cache in Firefox. the one I recommend is DNS Cache.

enter image description here

After restarting Firefox you should see a cog in the bottom (Similar to the Ubuntu cog in the upper right corner). You can left-click or right-click the Cog and you should see options like Enable/Disable DNS and Flush it. This will help in the case of the problem being the Firefox DNS Cache. Play with it.

I think I got all the ways you could solve that. If I missed something, let me know.

  • If Firefox doesn't respect the local machine's hosts file (that is, if the problem still occurs even after the domain with the www subdomain is added and even after the page is refreshed), I recommend reporting that as a bug. (I'm not sure what it would be a bug in, since Firefox presumably uses the operating system's DNS resolution facilities, which do, or are supposed to, respect it. But you could report it against firefox in Ubuntu and then further troubleshooting could likely retarget it from there.) Jan 9 '13 at 9:01
  • @EliahKagan It also depends on where and how the hosting/domain is. Some sites offer the option to enable using www subdomain and some do not have it preconfigured so when one tried to go to www.eliah.com it does not work, but eliah.com does. Jan 9 '13 at 13:21
  • Yes, of course. I'm not saying that www.foo.net should work just because foo.net works. Rather, if foo.net and www.foo.net are both defined to in /etc/hosts, typing foo.net in the address bar of a web browser and pressing enter should result in the browser attempting to open a connection to If it doesn't, there's a bug somewhere. Jan 9 '13 at 13:25
  • @EliahKagan - Ah! yes yes of course. In that case if it does not work the computer is possessed by a demon. We would either need an exorcist and a lot of holy water or a better diagnostic of the problem. Jan 9 '13 at 13:28
  • Exorcist + holy water and better diagnostic seems like the most prudent course. :) Jan 9 '13 at 13:35

I know that this thread is a year old, but I stumbled upon it searching for the answers to the very same problem. I finally found a solution! Turns out that the /etc/hosts file is being completely bypassed by DNS. To change this, you have to edit the /etc/nsswitch.conf and include files under hosts. Example below:

passwd:         compat
group:          compat
shadow:         compat

hosts:          dns files myhostname <-- this line here.
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

This will make sure that /etc/hosts file is included in the name resolution check. It will first check DNS and then the hosts file. I'm sure OP no longer needs this info, but this is still good for anyone seeking answers to this problem.

You must also restart in order for this to take into effect

  • I have "files mdns4_minimal [NOTFOUND=return] dns mdns4" in there on Ubuntu 12.04 but /etc/hosts still doesn't work... looks like I'm hitting a different issue.
    – Shnatsel
    Oct 28 '13 at 15:11
  • Can you paste the full code? Oct 28 '13 at 20:55
  • Here's the full config file: pastebin.com/hDBGrrwn I suppose this is the default on Ubuntu 12.04
    – Shnatsel
    Oct 29 '13 at 21:58
  • Everything looks right. What is it that you're trying to do? Oct 30 '13 at 22:00
  • 1
    It is worth mentioning that marked line should have exactly order like in your answer. I've got files dns ... and it didn't work. It has to be hosts: dns files ...
    – jmarceli
    Apr 23 '15 at 21:19

I believe etc/hosts is used on much lover level in the networking software stack than the browser itself. I.e. changes in that file should affect any browser.

What you're seeing may be a result of Firefox caching DNS entries - i.e. you opened the website in Firefox, Firefox remembers the IP address corresponding to adobe.com domain, you modified /etc/hosts and reloaded the page - Firefox does not issue a new DNS query and uses the cached data instead. Then you open Chrome, it makes a new DNS query and uses whatever you entered in /etc/hosts as the IP address for adobe.com

Restarting Firefox should fix the problem.


All the answers are great, but the shortest way to fixing it is:

after modifying /etc/hosts (and possibly restarting Firefox), reload the problematic tab with Ctrl+Shift+R. It will bypass any type of cache Firefox may have.


My problem was, I had multiple entries for same Domain Name. System saw only the first occurence. domain1.com domain2.com domain3.com # <-- WENT UNNOTICED
# .
# . domain1.com # <-- DOESN'T WORK

Could you try:

  1. Edit /etc/hosts file.
  2. Add next lines

     # /etc/hosts  localhost  myhost01  myhost02

in Ubuntu 14.04 changing /etc/hosts file to only have one host per line worked for me, i struggled for hours working with a IP host host host, than changed to IP host on each line and it worked >.<


I had this same issue on various versions of Ubuntu. The latest one reared its ugly head on 17.04 and 16.04. I found that I had to format the hosts file like this: localhost www.facebook.com facebook.com

ie you need to put in the url both the www and then again without. I have no idea why this works. Simply save the file and then ping the url as in:

ping www.facebook.com

and it should resolve to the loopback address or any other address that you want.eg:

80.82.xxx.xxx www.example.com example.com

Worked for me.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.