How to modify your hosts file

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:

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


  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
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to run MTR to diagnose network issues

MTR is a network diagnostic tool that combines traceroute and ping utilities. It enables system...

Archiving and extracting with Tar & Gzip

Tar is the best tool to pack an archive and Gzip is the most widely used archive type when using...

Finding files via SSH

Finding files and content in the command line can be tricky sometimes, but with a bit know...

SSH connection to MySQL

Connecting to your MySQL server via SSH can be very useful for developers and system admins and...

Using Putty to connect via SSH

Connecting to your Linux server via SSH is usually done via Putty at...