Filed under:

How do I change my hosts file? Or, how can I see my domain before DNS changes propagate?




To see your domain on our system before a DNS change takes effect ...

You simply need to edit your local hosts file on your device, to say "use these details instead of asking the internet where something is hosted".

  1. Open your 'hosts' file as an Administrator/with admin privilidges
  2. There should already be an entry for "localhost".
    Follow that format when you insert your FQDN [fully qualified domain name] and your IP
    Note that some machines have the format as IP [tab]FQDN and some as FQDN [tab] IP
    e.g.
    127.0.0.1 localhost
    or
    loaclhost 127.0.0.1
  3. Append your own entrie(s) to the file
    for example
    80.76.216.9 www.mynewsite.domain

    Add 1 line for each host/domain that you would like to map an IP to
    e.g.
    80.76.216.9 www.mynewsite.domain
    80.76.216.9 ftp.mynewsite.domain
    80.76.216.9 mail.mynewsite.domain
  4. Save this altered hosts file
  5. Optionally close notepad, depending on how long before you update DNS/Nameservers for real
  6. Please make sure your OS did not silently save the file as "hosts.sam" or similar
    The filename MUST BE just "hosts"
  7. Now you have modified your hosts file, you should flush your DNS so that you can see your changes. Depending on your OS, there are different ways to do this:
    • For Mac OS X the command is:
      lookupd -flushcache
    • For Windows the command is:
      ipconfig /flushdns
  8. You may also need to reboot for the change to take effect.
  9. You can "test" the new IP is resolved rather than the current value with
    ping FQDN from a command line/prompt

Now when you try to go to "www.mynewsite.domain", your browser (or other applications) will find that domain at the new IP instead of looking up the IP through your ISP or Network DNS (using the internet to resolve it)

Remember to remove the lince from your hosts file when you finally do update dns/nameservers on the domain

How to find the HOSTS file on your machine ...

If using Windows 7:

  • click "Start" > "All Programs" > "Accessories"
  • right click on "Notepad" and select "Run as administrator"
    (You may need to click "Yes" of "OK" for this to run with administrative privileges)
  • open your hosts file with "File" and select "Open"
    in the "File Name" area enter
    "%systemroot%\system32\drivers\etc\"
    and click "Open"
  • Click the drop down to the right of the "File Name" area and select "All Files"
  • Select the "hosts" file and click "Open".

If using Windows 10:

  • click "Start" > "Windows Accessories"
  • right click on "Notepad" and select "More" then "Run as administrator"
    (You may need to click "Yes" of "OK" for this to run with administrative privileges)
  • open your hosts file with "File" and select "Open"
    in the "File Name" area enter
    "%systemroot%\system32\drivers\etc\"
    and click "Open"
  • Click the drop down to the right of the "File Name" area and select "All Files"
  • Select the "hosts" file and click "Open".

If you are using Windows 95/98/ME/2000:

  • use "Start" > "Find" > "Files and Folders" to find a file in your windows directory (or WINNT\system32\drivers\etc) called "hosts"
  • Verify that the file is not "read only" by right clicking it, and choosing it's Properties
  • Then navigate to and open the file with Notepad

To find the hosts file in OS X's graphical interface:

  • Open Finder.
  • In the Go menu, select "Go to Folder"
  • Type /etc for the folder name.
  • In the list of files that appears, you should find hosts. Double click it to open it in a text editor.

To find the hosts file in Mac OS 9

  • look in your Preferences folder inside the System folder

On unix-based systems [ and possibly Apple OS X terminal ],

  • you can find the hosts file at
    /etc/hosts


Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
article icon Cron Cheat Sheet (Views: 3308)
article icon My website is down... (Views: 3202)

Language: