How to Change My Host File

You can set an IP address for a domain on a local computer by using and modifying host files. As a result they will override the DNS. There are some useful reasons to do that as follows: while visitors of your site search on it and use it, you can work by using one host file on a different server or there is no need to have link about testing your site, etc.

You should add two IP addresses and the address like:

Then the system will begin resolving of the addresses. After finishing, you can remove the written information.

By this article you will know the main instructions how to modify hosts file on different operating systems, described by steps below.

Windows as operating system use User Account Control (UAC), so Notepad will be Run as Administrator.

Windows 8, Windows 8.1, Windows 10, Windows NT, Windows 2000 or Windows XP

1. Go to the Start Menu and look for Notepad

2. Then press right-click and choose Run as Administrator

3. After you have done it, please open via Notepad the following file: c:\windows\system32\drivers\etc\hosts

4. Now, you can edit it.

5. After you finish, please save the changes by click File and then Save.

Note: The opening of Notepad in older version like Windows NT, Windows 2000 and Windows XP is via the following steps: Start – All Programs – Accessories – Notepad. The other steps are the same as described steps above.

Windows 7 or Windows Vista

1. To open directly Notepad and the host file, please go to Start Menu and write the following command in the Run line:

notepad c:\windows\system32\drivers\etc\hosts

2. Now, you can edit it.

For example:  If you want to block the access to a site, you should after all lines with the # mark to write:     

3. After you finish, please save the changes by click File and then Save.

4. Check if you can’t get to the selected site from the above example.


1. You can modify the host file by the terminal window. Open it.

2. Then open any text editor (as Notepad or Notepad++ or Sublime Text, etc.).

3. Write in it the following text:

sudo nano /etc/hosts

4. Write the domain user password.

5. Now, you can modify it.

6. Then press Control-x and Save the file by selecting “y”.

Mac OS X from version 10.0 to 10.1.5

1. Start with opening/Applications/Utilities/NetInfo Manager.

2. On the left corner select EditNetInfo Manager and enter the domain user password.

3. Then choose the node named machines from the second column of the browser view.

4. In the third column, select localhost. (The previous two columns are DHCP- and broadcasthost).

5. Go toEdit menu and select Duplicate. (This will save a part of your time!)

Note! Don’t stress – you will see a confirmation alert. Click Duplicate.

The new entry has name“localhost copy” and its properties will find in the browser view.

6. Go to the value of the ip_address property and by double-click write the IP address of other computer.

7. Then go to the value of the name property and by double-click enter the hostname.

8. Click the serves property and select Delete from the Edit menu.

9. Save the file via File menu.

You will see again the confirmation alert.

10. Click Update this copy.

Note: If you want to add additional hosts, it’s necessary to do again from step 6 to step 12.

11. Quit from the NetInfo Manager Menu.

Note: There is no need to restart the computer.

Mac OS X 10.6 - 10.10

1. Press Command and Space buttons together and write “Terminal”.

2. Then write the following command in the Terminal command prompt:

sudo nano /private/etc/hosts

3. Type your domain user password. Don’t panic you will not be able to see it.

4. Now, you can modify the host file.

Note: Add new mappings only after all the default mappings.

5. Then press Control+x and Save the file by selecting “y”.

6. To activate the new mapping write the following line by DNS cache:

dscacheutil -flushcache
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

reCapcha doesn't work on my WordPress site. How to fix it?

Question: I have some issues with my reCapcha on my WordPress site, how to fix it. It was just...

Is it possible to get a dedicated IP address for my webpage?

Question: Hello, Is it possible to get a dedicated IP address for my webpage? (I am planning to...

Problem with PHP WordPress memory

Question: I'm trying to increase the php memory limit to 128Mb in order to keep Woocommerce...

Ad banner module does not work in my host

Question: I installed an ad banner module, but gave me the following message:ForbiddenAccess to...

I can't access to my WP installation

Question: After copying the new site files to de main directory, I can not login into my...