0

I have my developer machine on which I work on web applications running under apache on Debian testing.

Now I like to be able to have myApp as domain name and not to have to use localhost or 127.0.0.1 in my browser address bar. Some CMS software doesn't support changing domains very well anyways... :-(

Now to do this I have a /etc/hosts file looking like this:

127.0.0.1 localhost
127.0.0.1 myApp
127.0.0.1 phpmyadmin 
....

In my apache settings I properly configure my virtualhost servernames.

This always worked fine, but today I had to share the internet with someone and when I unplug the cabel, I can't access myApp or other aliases anymore except localhost which now delivers me the document root of 'myApp' which it is not even configured to do in apache config...

I never really knew anything of DNS under Linux, but I think I have used this before without internet and it worked.

I haven't tried rebooting without the ethernet cable plugged in, maybe that would work but I am a bit puzzled and would like to understand and fix this problem

Since recently I do have another server (jetty) listening to localhost but on another port, but that might have nothing to do with it...

3 Answers 3

1

Your line in /etc/hosts must be converted to:

127.0.0.1 localhost localhost.localdomain myApp phpmyadmin
2
  • thanks alot, that did the trick. I used to have it like that, but then at some point I changed it... I don't remember why. I would upvote both answers, but don't have enough rep... will do so later.
    – user68729
    Jan 22, 2013 at 19:52
  • actually, sorry, I must have had a cached page in the browser because the problem persists... I haven't rebooted though (don't know if that is necessary).
    – user68729
    Jan 22, 2013 at 20:58
1

Your /etc/hosts looks scrambled for me.

In man hosts the following syntax is noted: IP_address canonical_hostname [aliases...]

So my advice is to use the following:

127.0.0.1 localhost myApp phpmyadmin
1

Make the changes earlier answers have suggested to your /etc/hosts file and make sure that "files" is listed in the "hosts" line in your /etc/nsswitch.conf file.

(/etc/nsswitch.conf controls, among other things, the order in which the resolver library consults various sources to try and resolve host names. if "files" isn't listed as a source /etc/hosts isn't consulted at all. In your case it probably makes sense to put "files" before "dns" on the hosts line.)

4
  • Thanks for the tip, 'files' is already the first entry on that line.
    – user68729
    Jan 22, 2013 at 20:59
  • Since you indicated above that you are still having problems.. What exactly do you get as the result of: "ping myApp"? Jan 22, 2013 at 21:51
  • ping myApp works fine and shows: PING localhost (127.0.0.1)...however firefox says Server not found
    – user68729
    Jan 22, 2013 at 23:58
  • ok, after rebooting it works. Thanks for your help
    – user68729
    Jan 24, 2013 at 21:51

You must log in to answer this question.