Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 trying to set up virtual hosts for local development and can't seem to get it working.

I have this in my httpd.conf:

NameVirtualHost *

<VirtualHost *>
 ServerName localhost
 DocumentRoot C:/Users/Elliot/dev/UniServer/www

<VirtualHost *>
 DocumentRoot C:/Users/Elliot/dev/UniServer/www/

and this in C:\Windows\System32\drivers\etc\hosts:       localhost

http://localhost resolves OK, does not.

Any ideas welcomed...

Edit: I'm pretty sure that my hosts file is the underlying problem and that any edits are being ignored.

Oddly, I can edit, save and delete it without elevated permissions, which should not be the case on Windows >= Vista.

Am working through 'What can cause a DNS lookup to ignore a hosts file entry?', 'HOSTS file being ignored' and 'Problem with the hosts file in Windows XP (as a new user I can't post links).

Edit: in my case, stopping the DNS Client service resolved the issue....

Edit: ...but only very briefly.

share|improve this question

migrated from Apr 27 '10 at 0:05

This question came from our site for professional and enthusiast programmers.

Looks good to me.Reboot your machine :) – systempuntoout Apr 26 '10 at 19:14
Done, no change. – e100 Apr 28 '10 at 12:20
up vote 0 down vote accepted

Do a ping of and make sure its resolving to your machine. Also, try setting the documentRoot to the same as the one above (C:/Users/Elliot/dev/UniServer/www/) just in case it's a premissions issue.

share|improve this answer
Hmm, ping fails. Any ideas? – e100 Apr 28 '10 at 7:01
If a ping fails- it means your host entry is not working properly- I would check this. – AliGibbs Apr 28 '10 at 11:44
OK, pretty sure it's a hosts problem, which is a different question. Have edited question to reflect this. – e100 Apr 28 '10 at 13:57

Look at the example here:

Set the IP address for the NameVirtualHost and then replace the * for each VirtualHost with the qualified name (localhost for the first and for the second).

share|improve this answer
Make sure you add a ServerAlias as well for to: ServerAlias * – Jon Apr 26 '10 at 19:14
Thanks but as per AliGibbs' answer, it looks like the underlying issue issue is with the hosts file. – e100 Apr 28 '10 at 12:22

Try putting on the same line as localhost in your hosts file, e.g:   localhost
share|improve this answer

Do you have this entry :

NameVirtualHost *

It allows you to enable the vHosts

share|improve this answer
Yes, in my question, it's the first line I quote from httpd.conf – e100 Apr 28 '10 at 14: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.