0

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!

MRashid
  • 121
  • 1
  • 1
  • 5
  • 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
  • @Ocelotx10: You need to do something to cause the browser to connect to that server when you punch "mysiteb.com" into the browser. That could, for example, mean creating an entry on the DNS server that machine uses. – David Schwartz Feb 28 '13 at 22:38
  • @DavidSchwartz What is the /etc/hosts file supposed to do? – MRashid Feb 28 '13 at 22:40
  • @Ocelotx10: Many things such as allow the system to determine its own IP address before DNS is working, allow the system to locate its DNS servers by name, and quite a few other things -- but *not this*. See the second paragraph of the Wikipeda entry on [/etc/hosts](http://en.wikipedia.org/wiki/Hosts_%28file%29#Purpose). – David Schwartz Feb 28 '13 at 22:46
  • @DavidSchwart http://en.wikipedia.org/wiki/Hosts_%28file%29#Extended_applications – MRashid Feb 28 '13 at 22:51
  • @Ocelotx10: Do you know for a fact that works with your browser? – David Schwartz Feb 28 '13 at 23:09

1 Answers1

0

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.

Jay
  • 6,544
  • 25
  • 34
  • 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