How to modify your hosts file Print

  • 47

By modifying your hosts file on your local PC you can override the DNS for a domain. This is useful if you need to view how a website will look on a particular ip before you update the DNS for it such as when you change web hosting providers without using the test link/url. 

To modify the host files you will need locate it on your PC whether it's Windows, Linux, or Mac. You need to add two entries to the file with the domain and ip address you want the website to resolve to. For example you will add this to the file:

104.31.87.149 www.domain.com
104.31.87.149 domain.com

The following section provide instructions on locating and editing the hosts file on the following operating systems.

  • Windows
  • Linux
  • Mac OS



Windows NT, 2000, XP, 7, Vista, 8, and 10

  1. Navigate to notepad, right click and run it as administrator
  2. Open and go to C:\Windows\System32\drivers\etc\hosts
  3. Open the hosts file and make the changes and save

Linux

  1. Open a terminal window
  2. Open the hosts file in a text editor by typing the following line:
    sudo nano /etc/hosts
  3. Enter your domain user password
  4. Make the changes to the file and press Control-x
  5. When asked if you want to save your changes, answer y.

Mac OS

  1. Open Applications > Utilities > Terminal
  2. Open the hosts file by typing the following line in the window
    sudo nano /private/etc/hosts
  3. Type your domain user password 
  4. Edit the hosts file
  5. Save the hosts file by pressing control+x and answerying y.

When you are done flush your DNS by opening your command prompt and typing: ipconfig /flushdns

Was this answer helpful?

« Back