Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm hitting the most frustrating problem with the devlopment environment on my Mac at work (OS X 10.6.6, Apache 2.2.15, PHP 5.3.3 - all default installs with very little modification). Last night I started working on a new website, I added a virtual host and added a few domains to /etc/hosts to resolve to my local machine.

My hosts file entry looks like this:

And my virtual host looks like this:

<VirtualHost *>
    DocumentRoot "/Volumes/Websites/ExampleClient/"
    ServerAlias *

I'd like to think it's something stupid I've done, but the annoying thing is it was working last night! The only thing that's changed since then is that I restarted my machine this morning. The domain works as expected, but doesn't, the request drops into the default virtual host at /Volumes/Websites/Personal/Rowan Manning.

Things I've tried:

  1. Explicitly setting as a virtual host ServerName with no aliases
  2. Restarting apache with sudo apachectl restart;
  3. Restarting apache with sudo apachectl stop; sudo apachectl start;
  4. Restarting my Mac (again)
  5. Checking that the /Volumes/Websites/ExampleClient/ directory is OK
  6. Checking the permissions for /Volumes/Websites/ExampleClient/
  7. Checking that I'm editing the right virtual hosts file by forcing it to error

I'm stuck! Any ideas?

Edit (21st March 11):
The problem seems to have resolved itself over the weekend. I haven't changed anything, yet again... I'm completely mystified but glad it's working!

share|improve this question
Look at logs (error.log and access.log) – NARKOZ Mar 16 '11 at 11:35
I just did, but there's nothing there to indicate a problem. The access log just shows requests to / and /favicon.ico and the error log contains nothing related to this (just some PHP errors and missing favicons etc.) – Rowan Mar 16 '11 at 12:19
Do you have NameVirtualHost *:80 somewhere in your config? – Marcin Mar 16 '11 at 13:54
I do have a NameVirtualHost * in my config @Marcin, see comments on @Jari's answer below for more details – Rowan Mar 16 '11 at 15:27

Some thoughts:

1) Try adding the port number to the VirtualHost directive, like

<VirtualHost *:80>

Make sure that it matches with the port number of the default VirtualHost directive and the NameVirtualHost directive.

2) Try using IP address instead of, if the server is on localhost.

3) Remember to reload the page in your browser (or better, restart the browser), and not just access the domain directly, after you have changed the configuration.

4) How does your default VirtualHost configuration look like?

share|improve this answer
Thanks Jari, I didn't mention but I have tried points 1–3 without any luck. My default virtual host is like this: <VirtualHost *> DocumentRoot "/Volumes/Websites/Personal/Rowan Manning" </VirtualHost> – Rowan Mar 16 '11 at 12:54
Do you have ServerName defined for the default VirtualHost? Also, make sure you don't have DocumentRoot directives specified outside the VirtualHost blocks (in httpd.conf or somewhere else). – Jari Jokinen Mar 16 '11 at 13:47
And, you could try sudo apachectl -t -D DUMP_VHOSTS if you'd like to see more information about your virtual host configuration. – Jari Jokinen Mar 16 '11 at 13:54
Thanks for those (I didn't know the DUMP_VHOSTS bit - really useful) but still not working! Banging my head against the desk here... The annoying thing is that and even work fine, but doesn't. I don't even understand how that's possible! There are no other virtual host configs that reference the domain – Rowan Mar 16 '11 at 15:24

Your Answer


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.