I'm learning how to host websites on a small server at home. I followed some tutorials where they said you had to edit the "hosts" file (C:\Windows\System32\drivers\etc\hosts) and add the following: domain.com

After I would go to my "httpd-vhosts.conf" and enter something like this:

<VirtualHost *:80>
    ServerName domain.com
    DocumentRoot C:/Apache24/Websites/domain.com

Finally, I would go to Godaddy and have it point domain.com to my home IP.

Everything works great but just to do some testing I decided to remove the lines in the "hosts" folder leaving it empty. Restarted my apache service and the websites are still accessible.

So is modifying the hosts file even necessary?

Thanks for the help!

  • The DNS (Doamin name Sytem) has a TTL value (Time To Live) which will suppress negative effects surfacing at once, don't play with it. – LotPings Nov 8 at 22:11
up vote 0 down vote accepted

If you have an external DNS service (like GoDaddy) configured to point to your local IP for the specific domain name you want to use, you do not need the hosts file.

You only need the local hosts file if you do not wish to set up an external DNS resolver. If you make entries in the local file, no external computer would find your IP, when the domain name is entered, only your local computer with this hosts file can find it like that.

With an external DNS service configured, any computer using this external service can find your IP with the host name.

  • So you could say there are 3 levels of DNS: 1- DNS only in your computer (hosts file) 2- DNS only in your local network (local dns server or router with “DNS Host Mapping") 3- Intenet DNS server that can be updated using Godaddy for example – Alvaro Bataller Nov 8 at 23:31
  • It can be even more levels. To quote Wikipedia's DNS article: "Each server refers the client to the next server in the chain, until the current server can fully resolve the request. For example, a possible resolution of www.example.com would query a global root server, then a "com" server, and finally an "example.com" server". Local hosts file will always be the first (just try to add an entry ' facebook.com' and visit that mean domain after that ;-)). – Jaleks Nov 8 at 23:35
  • Great, so that hosts file would be useful if i want to access my own website "domain.com" without going out to the internet and back into my network? By adding domain.com i would be routing the request to webserver itself instead of to the router then to the internet dns server and then back to the router and finally to the server machine. – Alvaro Bataller Nov 8 at 23:39
  • exactly, thats like it works – Jaleks Nov 8 at 23:40

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.