How to adjust your hosts file (Mac)

When you are creating a new website but don't want to make it live yet, it is possible to test your website locally. This can be done by making a (temporary) adjustment in the hosts file on your computer.

This adjustment directs the domain name you entered to a specific IP address, instead of the IP address determined by DNS.

Here's how you can do this on a Mac:

Step 1:

Open Terminal (via Spotlight).


Step 2:

Enter the code sudo nano /etc/hosts and press Enter.


Step 3:

Enter your password and press Enter (it's normal that no characters appear on your screen).


Then the host database will open.


Step 4:

Enter the IP address and your domain name as follows:



Step 5:

Save the file using the keyboard shortcut Control + X.

Step 6:

Then press Y, followed by Enter.