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

In my pc (running on Ubuntu) , I have configured apache and php. I wanted to create a subdomain 'mysite.localhost' on my localhost

I have a folder /var/www/mysite Which I would like to access like http://mysite.localhost/

I followed the steps in

Basically did the following

Edited /etc/host and added the following line mysite.localhost

Created a new configuration file in /etc/apache2/sites-available/mysite using

gksudo gedit /etc/apache2/sites-available/mysite

<VirtualHost *:80>
    DocumentRoot /var/www/mysite
    ServerName mysite.localhost

    <Directory /var/www/mysite>
        Options Indexes FollowSymLinks MultiViews +Includes
        AllowOverride all
        Order allow,deny
        allow from all

Saved the file, and run the following:

sudo a2ensite mysite

Finally restarted the Apache Server.

sudo /etc/init.d/apache2 restart

But on browsing http://mysite.localhost/ I get this message

" Network Error (dns_unresolved_hostname) .Your requested host "mysite.localhost" could not be resolved by DNS. "

Can anyone suggest what could be going wrong?

share|improve this question

migrated from Nov 30 '11 at 11:26

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

I have a couple of suggestions that might help, but these are just "shots in the dark" since I don't have access to a system right now that I can set up with a similar situation to yours for testing.

  1. If you had your browser running prior to editing /etc/hosts, then restart your browser. That should allow it to pick up changes to your hosts file.
  2. In your question, you state that you want to serve your mysite files from /var/www/mysite, but in your Apache config file, you specify that the directory will be served from DocumentRoot /home/username/mysite/. One of the two needs to change; either your expectation that the files will come from /var/www/mysite, or the DocumentRoot must be set to /var/www/mysite (and correspondingly, the <Document ...> declaration must then change as well.)

If neither of these work, then you should also try pinging the system to make sure it's responding correctly, as in the following:

$ ping mysite.localhost
ping: unknown host mysite.localhost

$ sudo vi /etc/hosts
(/etc/hosts now reads:   localhost mysite.localhost)

$ ping mysite.localhost
PING localhost ( 56(84) bytes of data.
64 bytes from localhost ( icmp_req=1 ttl=64 time=0.044 ms
64 bytes from localhost ( icmp_req=2 ttl=64 time=0.037 ms
share|improve this answer
you are right about correcting the document root directory path.I checked the path I have set and it is indeed pointing to the correct path (I made a typo while asking the question,i'm going to correct it).About pining the subdomain, that works too. but simply cannot browse the url mysite.localhost :-( – Annibigi Dec 1 '11 at 6:11

Everything seems to be okay. Please double check following entries in their respective files. mysite.localhost

ServerName mysite.localhost
share|improve this answer
did check..Everything appears to be as it should . – Annibigi Nov 30 '11 at 10:17
up vote 0 down vote accepted

I resolved this issue. Apparently, there is nothing wrong with the sub-domain creation process. I could not access the page because of some proxy settings. I bypassed all proxy settings for localhost, (to do this in Ubuntu: go to browser Edit>Preferences>Advance>Network >Settings tab and set localhost, for No proxy field ) And now it works!

share|improve this answer

Make sure you have added localhost and entries in proxy server ,

Path: google chrome-->settings--> Show advanced settings--> Change proxy settings--> lan settings --> proxy server/advanced/ and add entries in the Exceptions box.

share|improve this answer

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.