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.

My /etc/hosts file is configured as following:

127.0.0.1 localhost mysitea.local mysiteb.com www.mysiteb.com www.mysitea.local

And I have my Apache virtual hosts setup accordingly:

    <VirtualHost *:80>
        ServerName www.mysitea.local
        ServerAlias mysitea.local

        WSGIScriptAlias / /var/www/mysitea/apache/django.wsgi


        <Directory /var/www/mysitea>
        Order deny,allow
        Allow from all
        </Directory>
   </VirtualHost>

   <VirtualHost *:80>
          ServerName www.mysiteb.com
          ServerAlias mysiteb.com

          WSGIScriptAlias / /var/www/mysitea/apache/django.wsgi

          <Directory /var/www/mysitea>
          Order deny,allow
          Allow from all
          </Directory>
   </VirtualHost>

When I type mysitea.local in the browser, the hostname is resolved as expected. However, the hostname is not resolved when I type mysiteb.com in the browser. It does work when I ping to the hostname. I get the same issue every time I try to add a ".com" hostname.

Edit: I highly doubt that this is a cache refresh issue. I have reset my cache several times and tried again and it still doesn't work!

share|improve this question
    
What IP address is returned when you ping the .com? –  longneck Feb 28 '13 at 21:02
    
In both cases, the ip address returned is 127.0.0.1. –  MRashid Feb 28 '13 at 21:14
    
"However, the hostname is not resolved when I type mysiteb.com in the browser." What have you done to make this work exactly? I see lots of things to make it work in the web server, but I don't see anything to make it work in the browser. –  David Schwartz Feb 28 '13 at 22:10
    
This could also be a problem with /etc/nsswitch settings (though I'd expect that rather with the .local name) –  Hagen von Eitzen Feb 28 '13 at 22:19
    
@DavidSchwartz: Please excuse my lack of understanding but what else do I need to do other than what I've done? I've remapped the hostname in the /etc/hosts file, setup the virtual host and the site. Moreover, as mentioned above, the setup is exactly the same as that for mysitea.local which works as expected. –  MRashid Feb 28 '13 at 22:27

1 Answer 1

I'll take a guess: your browser is actually requesting www.mysiteb.com (or its cached the result for www.mysiteb.com has non-resolving). Add that to your hosts file too, and it should work just fine.

127.0.0.1 localhost mysitea.local mysiteb.com www.mysiteb.com

If it still doesn't work, clear your browsers cache and/or restart your browser.

share|improve this answer
    
Thanks for the prompt reply. I've already tried that and it still doesn't work. I also delete my cache and cookies but it doesn't work either. (I've updated my question to reflect this). –  MRashid Feb 28 '13 at 21:13
    
How about from a terminal? curl -v http://www.mysiteb.com/. Can you add that to your question? –  Jay Feb 28 '13 at 21:44
    
I get an HTTP/1.1 502 notresolvable error. –  MRashid Feb 28 '13 at 22:36
    
What IP is it connecting to? If it's 127.0.0.1 and you're getting that, then your hosts file is working fine. Your Apache installation is causing problems, which is a new question. –  Jay Feb 28 '13 at 22:44

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.