How Do I Change My Hosts File?


The hosts file is a file on your PC that can override the default DNS of the network you're on - essentially allowing you to designate what server the hostname (or domain) will point to. For example, you could set a hostname that points to and see what happened (it would break! But sometimes it can be useful, like if an ISP DNS cache has broken a hostname's connection to it's IP address).


How to Recognise a Hosts File?

The hosts file is a regular text file, usually called “hosts”. Regularly, a host file will reference your local computer “localhost” and will look like below; localhost



The hosts file can be edited (as it’s a regular text file) and allow your local machine to delegate a domain name to a specific IP address, regardless of whatever the network might delegate it to.

What’s The Point In Changing It?

You can change the hosts file to point your domain to a preview server to work on a new version of the site, or you can use it to override the default DNS cache on your network/ISP due to an incorrect cache or other issue.

Editing Your Hosts File

In order to change the hosts file, you’ll need to know the IP address of the server (you can use What’s My DNS or a Google Dig to find out) or by checking in your cPanel console.

Once you know what your IP address is, you can either use a browser plugin to edit the file or you can simply edit it yourself in the system file.

Using A Browser Plugin

There are multiple plugins that can do this for both Firefox and Chrome. A quick Google search should be able to uncover them, but as a quick guide the most popular ones are listed below by browser;



It’s important to keep in mind that each plugin has a different method for use, and you should consult their individual documentation for best results.

Editing System Files

Alternately, you can alter the host your PC loads the website from by editing the hosts file yourself.

This might be easier for you depending on your level of comfort with your operating system and altering system files.

The hosts file looks like the example below; localhost



The second line in the example is the one you’ll need to add. Simply replace “123.456.679.10” with the IP address of the designated server, and replace “” with the correct domain name.

You can de-activate a line by adding the hash symbol (#), which causes the line to be ignored. Specific instructions for popular OS are below.


Windows 10/8

  1. Open the File Explorer
  2. Click "This PC" in the sidebar, then navigate to c:\Windows\System32\Drivers\etc\hosts
  3. Open the "hosts" file with Notepad (you may have to open Notepad as an administrator to make changes)

Windows 7 or Vista

  1. Select Start > All Programs > Accessories
  2. Right click Notepad and select Run As Administrator
  3. Click Continue on the permission window
  4. In Notepad, select File > Open
  5. In the file name text box, type (or paste) C:\Windows\System32\Drivers\etc\hosts
  6. Select Open

Once you've made it to the host file, make the necessary changes and save the document. Once you've done that, be sure to clear your browser's cache (Instructions for Chrome/Instructions for Firefox) and then reboot your computer.

Mac OS X

  1. Open a Finder window
  2. Select Applications from the sidebar
  3. Double-click on Utilities
  4. Double-click on Terminal

In the Terminal window, you will need to enter a command to open the Nano text editor. You will need your administrator password.

      5. type sudo nano /etc/hosts and then hit return.
      6. Enter your administrator password and then hit return.

If you want to add a new device or domain, move the cursor using the arrow keys and position it after the text in the window. Then, begin typing.

If you're mapping a particular IP address on your local network to a domain, you can type the IP address, hit tab, then type the domain name.

Conversely, if you'd like to make sure a web URL doesn't go to its intended site — if you're trying to keep your Mac away from certain sites, use "" That'll map it back to your Mac. Even if your Mac is assigned a different IP address by its router, defaults to the local machine thanks to the default settings in that hose file.

Once you're done, hold down the control and O keys to save the file, then control and X to exit.

Back at the command line, type sudo killall -HUP mDNSResponder then type return. That will flush your Mac's DNS cache, so it doesn't get confused by any changes you've made to the Hosts file.

(Thanks to for this information -


On Unix-based systems, you can find the hosts file at /etc/hosts. Most distributions of Unix will have terminal located in the same location.

To open the terminal:

  1. Go to Menu.

  2. Select Applications.

  3. Choose Accessories.

  4. Select Terminal.

To edit the hosts file:

Unix users can edit hosts files in the same process as Mac users. Please refer to the above steps to make the necessary changes.

DNS Flush

Once you have modified your hosts file, it is recommended that you flush your DNS so that the new changes can be implemented more swiftly. DNS flushing must be done using command line. Depending on your computer's OS, there will be different commands. For more detailed instructions, please check the flush DNS page at WhatsMyDNS.

Was this article helpful?
0 out of 0 found this helpful