Search the CLDY knowledge base

Updated on September 17, 2022

How to Modify your Hosts File in Windows and Mac?

When do you need to edit your Hosts File

Hosts file (hostfile) needs to be modified in cases when you need to manually override the DNS (domain name system) for a specific domain. When you do so, your local computer can directly access the IP address that you have specified in your hosts file.

What you need to do is to add two entries: an entry for the IP address that you want the site to resolve, and an entry for one version of the web address of the domain. This is an example:


How to edit your Hosts File

Select your corresponding OS and follow the steps as provided:

For Windows

  1. Hit the Windows key from your keyboard.
  2. Search “notepad”.
  3. Once the search results come up, right-click on Notepad and click on Run as administrator.
  4. You may receive an alert “Do you want to allow this app to make changes to your device?” Click on Yes.
  5. From Notepad, click on File, then Open (or hit Ctrl + O from your keyboard), and search for this filename:
  6. At the last line, add the necessary information.
  7. Click on File, then Save, to save the modifications you have added.


For Mac

  1. From Finder, go to Applications.
  2. Then click on Utilities.
  3. And go to Terminal.

  4. The Terminal window will now open.

    Enter the command as follows:
    sudo nano /private/etc/hosts

  5. You will be asked to enter your user password. Type it in and hit Enter.
  6. The hosts file will now open.

    Add your changes after the last line.
  7. Click on Control + X to save the changes to the hosts file. You will be prompted to confirm the changes – click on Y on your keyboard.
  8. Then press Control+T to go back to the Terminal window.
  9. Enter this command in the Terminal window to force the changes to take effect:
    dscacheutil -flushcache

Still can't find what you're looking for?