How to edit your hosts file on Windows, Mac, or Linux Print

  • 2

Editing your local systems hosts file allows you to manually point a website to a specific IP instead of relying on public DNS resolution. The hosts file is located in the following locations depending on your system:

  • Windows 10 – “C:\Windows\System32\drivers\etc\hosts”
  • Linux – “/etc/hosts”
  • Mac OS X – “/private/etc/hosts”

Editing your host file on Windows:

  1. Click the Windows button and type notepad to bring up the notepad utility.

  2. Right click on notepad and click Run as Administrator

  3. You’ll be asked “Do you want to allow this app to make changes to your device?”. Choose Yes.

  4. In your notepad click File and then Open

  5. Navigate to C:\Windows\System32\drivers\etc\hosts or click the address bar at the top and paste in the path and choose Enter.  If you don’t see the hosts file in the C:\Windows\System32\drivers\etc\hosts directory then select All files from the File name: drop-down list, then click on the hosts file. 

  6. Once you're viewing the host file add the entries one per line as needed. The correct format to use is:

    1.2.3.4 hawkhost.com

  7. In the above example replace 1.2.3.4 with the IP address you want to point your site to and replace hawkhost.com with the domain name you're working with.

  8. Once you have added your hosts entries save the hosts file. Your domain(s) will now be manually pointed to the IPs listed in the host file.

Editing your host file on Mac:

  1. Open the Terminal app by using either the Spotlight search or by navigating to Applications=>Utilities=>click Terminal

  2. In the Terminal you just opened type the following command: sudo nano /private/etc/hosts

  3. Type in your user password when prompted

  4. Edit the hosts file using the following format:

    1.2.3.4 hawkhost.com

  5. In the above example replace 1.2.3.4 with the IP address you want to point your site to and replace hawkhost.com with the domain name you're working with.

  6. Save your changes by pressing control-o on your keyboard then return to accept the filename. Exit the editor by pressing control-x. This takes you back to the terminal screen.

Editing your host file on Linux:

  1. From your command line terminal type the following command: sudo nano /etc/hosts

  2. When prompted enter your password to allow your user the ability to modify/save the hosts file

  3. Edit the hosts file using the following format:

    1.2.3.4 hawkhost.com

  4. In the above example replace 1.2.3.4 with the IP address you want to point your site to and replace hawkhost.com with the domain name you're working with.

  5. Save your changes by pressing control-x on your keyboard then y to save the changes and return to complete the save. You will be dropped back to your command line terminal.

Was this answer helpful?

« Back

Ready to get started? Build your site from
$2.24/mo
GET STARTED NOW