Skip to main content
local host file

Test website with the hosts file

If you moved your website to a new server and you want to test it before it completes propagation of DNS records or just develop a site that is not yet publicly available, you can do so by modifying the local host file.
Entering IP address of a new server in the host file on your computer, you can force the browser to access the desired location. This is possible because the record in the local host file has priority over DNS records.

We will describe how to modify the host file on Windows, Linux and OSX operating systems.

Windows

    1. Run Notepad as an administrator (right click on the icon and select “Run as administrator”). This is necessary to be able later to save the changes.
    2. Open the host file with File > Open … Select “All files” in the field for the extension. Host file is located at:

C:\WINDOWS\system32\drivers\etc\hosts
notepad host file

    1. At the end of the file, type the IP address of the server and web address of a site. For example:

10.11.126.18 mojdomen.com

    1. Save the changes File > Save
    2. It is necessary to delete the local cache from the computer. Start a command prompt, Start> Run> CMD and enter the following command:

ipconfig /flushdns

  1. Restart your browser and, if necessary, delete the cache of the browser.

When finished testing site, you can restore the host file to the old state.

Linux / OSX

Change the file etc/hosts as root.
In OSX you can find the Terminal.app in Applications > Utilities > Terminal.
Type the IP address of the server and web address of a site. For example:
10.11.126.18 mojdomen.com
Restart the nscd daemon by entering the following in a terminal window:

On OSX enter the following command
OSX prior to 10.5:
lookupd -flushcache
OSX 10.5 or later:
dscacheutil -flushcache

SkyHosting

Best Hosting Services: .rs domain registration, Web Hosting, VPS Servers, SSL Certificates. Visit us SkyHosting.

Leave a Reply

Your email address will not be published. Required fields are marked *