Modifying your hosts file allows you to override the DNS for a domain, on that particular machine. This is useful when you want to test your site without updating your domain to the new site yet.
You will be given an IP address and the domain name to add to your hosts files. Usually in this format:
54.39.229.198 www.domain.com
54.39.229.198 domain.com
These 2 lines with your new ip address and domain is what you will be entering into your hosts file.
Here are the instructions based on the various operating systems
Windows 10
- Press the Windows key.
- Click the Search icon
- Type Notepad in the search field.
- In the search results, right-click Notepad and select Run as administrator.
- In Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
- Make the necessary changes to the file.
- Click File > Save to save your changes.
For Windows 8
- Press the Windows key.
- Type Notepad in the search field.
- In the search results, right-click Notepad and select Run as administrator.
- In Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
- Make the necessary changes to the file.
- Click File > Save to save your changes.
For Windows 7
- Click Start > All Programs > Accessories.
- Right-click Notepad and select Run as administrator.
- Click Continue on the Windows needs your permission UAC window.
- When Notepad opens, click File > Open.
- In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
- Click Open.
- Make the necessary changes to the file.
- Click File > Save to save your changes.
Mac OS X 10.0 through 10.1.5
- Open /Applications/Utilities/NetInfo Manager.
- To allow editing of the NetInfo database, click the padlock in the lower-left corner of the window.
- Enter your domain user password and click OK.
- In the second column of the browser view, select the node named machines.You will see entries for
-DHCP-
,broadcasthost
, andlocalhost
in the third column. - In the third column, select
localhost
. - From the Edit menu, select Duplicate. (The quickest way to create a new entry is to duplicate an existing one.)A confirmation alert appears.
- Click Duplicate.A new entry called localhost copy appears, and its properties are shown below the browser view.
- Double-click the value of the
ip_address
property and enter the IP address of the other computer. - Double-click the value of the
name
property and enter the hostname you want for the other computer. - Click the
serves
property and select Delete from the Edit menu. - From the File menu, select Save.A confirmation alert appears.
- Click Update this copy.
- Repeat steps 6 through 12 for each additional host entry that you want to add.
- From the NetInfo Manager menu, select Quit.You do not need to restart the computer.
Mac OS X 10.6 – 10.10
- Open Applications > Utilities > Terminal.
- Open the hosts file by typing the following line in the terminal window:
sudo nano /private/etc/hosts
- Type your domain user password when prompted.
- Edit the hosts file.The file contains some comments (lines starting with the # symbol), and some default hostname mappings (for example, 127.0.0.1 – local host). Add your new mappings after the default mappings.
- Save the hosts file by pressing Control+x and answering y.
- Make your changes take effect by flushing the DNS cache with the following command:
dscacheutil -flushcache
The new mappings should now take effect.
← Support