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...

Chetan Bhargava
  • 245
  • 5
  • 15

3 Answers3

1

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

127.0.0.1 localhost localhost.localdomain myApp phpmyadmin
  • 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. –  Jan 22 '13 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). –  Jan 22 '13 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
H.-Dirk Schmitt
  • 644
  • 4
  • 9
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.)

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