Skip to main content

Introduction

If you want to be able to change the resolution of domains to Its for a specific local machine, you will want to be able to change your hosts file.

Your hosts file allows you to tell a specific computer to resolve a domain to a specific IP address, which can be handy for developers, personal networking setups and a range of other advanced tasks, including blocking connections to certain domains.

Parts

No parts specified.

  1. You can find Terminal in Applications or Launchpad, usually under Utilities
    • You can find Terminal in Applications or Launchpad, usually under Utilities

    • This will change the directory to where we need to issue the next command

    • The command sudo gives you full administrator access to your machine, and so should be used very carefully - as such, it will ask for your administrator password

    • Nano is a command line text editor, and so will allow you to edit your hosts file

  2. You can add new entries to the end of the file
    • You can add new entries to the end of the file

    • Add the IP address you want to resolve to first, and then place the domain name you want to resolve to that IP address afterwards

    • e.g. 1.2.3.4 domain.com

    • Existing entries in the file can be used as a template, but don't change them!

    • If you want to block a domain name from working, you can direct it to a false IP address such as 0.0.0.0

    • e.g. 0.0.0.0 blocked.com

    • Once you are finished editing, press Ctrl + X on your keyboard to exit, and then press Y when asked whether you want to Save or 'Write Out' (another term for saving)

    • In most instances, after you save your Hosts file, it should work instantly. However, sometimes you may need to flush your DNS cache before it starts to take effect

    • To do this, enter in Terminal 'sudo killall -HUP mDNSResponder' and press return

    • Remember to exclude the quotation marks

Finish Line

Adrian

Member since: 01/10/2020

2,179 Reputation

15 Guides authored

0 Comments

Add Comment

View Statistics:

Past 24 Hours: 0

Past 7 Days: 0

Past 30 Days: 0

All Time: 56

Please back up your files before attempting any guides on this site, and be aware that any of these solutions are carried out at your own risk. Solve The Fruit is not responsible for any outcomes for following these crowd-sourced guides.

Solve The Fruit is an independent open-source solutions and guide website and is not affiliated with Apple Inc in any way.