Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Virtual Hosts without Internet connection

Status
Not open for further replies.

GooseVT

Programmer
Mar 15, 2008
4
US
(This question got a little long, here's the straight skinny: I'm unable to browse using virtual host names on a development machine while disconnected from the internet.)

I'm using Apache (2.2.4) on Windows XP for offline development. To make it as seamless as possible I use a Virtual host for each site I'm developing. It all works great - but only if I'm connected online. Once I move away from an Internet connection - such as at a client meeting for a demo (embarassing) or to a cabin by the lake (a blessing) - I can't use the virtual name to reach the site.

Here's how I'm set up.

In my apache config I have (for example):
NameVirtualHost *:80

<VirtualHost *:80>
ServerName notquiteacashcow.local
DocumentRoot "K:\WebDev\notquiteacashcow.com"
</VirtualHost>

In Windows' hosts file I have the line:
127.0.0.1 notquiteacashcow.local

As I said, everything works when I'm connected, but with the router turned off/cable disconnected/no wireless available I get "Server Not Found" errors in the browser and cannot ping the virtual name.

I can still browse to and ping either "localhost" or 127.0.0.1 and get to Apache's htdocs directory, but pinging notquiteacashcow.local gives, "Ping request could not find host notquiteacashcow.local. Please check the name and try a
gain."

I realize that the ping results show that this is not a problem with Apache, but I'm hoping that someone out there has also wanted to do some truly offline development and was able to solve this issue. During my Google research I've seen this question asked in various forums but it never seems to get any responses, let alone an answer.

A nudge (shove?) toward a more appropriate place to ask this question will be nearly as appreciated as a solution...
 
I'm surprised that it stops working when you're not connected to the network. Have you tried adding your virtualhost names to the lmhosts file? In theory, it shouldn't make any difference with tcp/ip name resolution, but it's worth a try.
 
I think you need to keep at least localhost in there, but I wonder how are you able to ping localhost once offline if you have only that line in localhost?

Do you "ipconfig /flushdns" after each change?

I have read articles with newer XP where it should work the opposite, that if the DNS client is "active" it disables hosts file processing, but yours seems reversed.
 
I mistyped. I wonder how your are able to ping localhost once offline if you have only that line in THE HOSTS FILE.

I would keep localhost and add your entry:

127.0.0.1 localhost
127.0.0.1 notquiteacashcow.com
 
smah: Yes, I had tried adding it to lmhosts, and as expected it did not work.
 
elgrandeperro: Freaky, eh? I can ping localhost with a completely empty host file, in fact. I do usually have localhost in there, but I was going as barebones as I could to keep it as simple as possible.

Your comment about my situation being reversed turned out to be right on the money! I couldn't flush the DNS cache because DNS Client wasn't running. Once I started the service so I could double check that I could ping all of my virtual hosts as expected.... and more importantly resolve them in the browser.

I hadn't tried starting DNS Client because I'd also seen where that could be the source of the problem so I specifically made sure it wasn't running!

Is there a compelling reason to keep DNS Client active or not? Apparently I'd never had it running and didn't notice until this came up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top