modify hosts file

Looking for a video tutorial?


By modifying the hosts file on your PC you can override the DNS for any number of domains. This is useful if you need to view how a website will look on a particular IP before you update the DNS. When you change web hosting providers, for example or even when you don't want to use a preview link / url.

Just add two entries to the host file with the domain and IP address you want the website to resolve to. For example add this to the file:

204.188.245.89 www.domain.com
204.188.245.89 domain.com

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

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
  4. *flush your DNS if you wish by typing ipconfig /flushdns into Run box
flush-dns-cache

Linux

  1. Open a terminal window
  2. Open the hosts file in a text editor by typing the following line:
  3. sudo nano /etc/hosts
  4. Enter your domain user password
  5. Make the changes to the file and press Control-x
  6. 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
  3. sudo nano /private/etc/hosts
  4. Type your domain user password
  5. Edit the hosts file
  6. Save the hosts file by pressing control+x and answerying y.
  7. When you are done, please flush your DNS by opening command prompt and typing: ipconfig /flushdns