Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

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

127.0.0.1 localhost localhost.localdomain myApp phpmyadmin
share|improve this answer
    
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. –  ufotds 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). –  ufotds Jan 22 '13 at 20:58
    
after rebooting it works! thanks alot –  ufotds Jan 24 '13 at 21:51
add comment

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

share|improve this answer
    
Thanks for the tip, 'files' is already the first entry on that line. –  ufotds 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 –  ufotds Jan 22 '13 at 23:58
    
ok, after rebooting it works. Thanks for your help –  ufotds Jan 24 '13 at 21:51
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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