Apr 28, 2022
Domantas G .
2min understand

How to Locate and Edit Hosts File on Mac

How to Locate and Edit Hosts File on Mac By editing Mac hosts file, it ’ s potential to emulate DNS deepen and set the coveted IP for a knowledge domain mention. With the hosts file you can overwrite any DNS values set by your Internet service supplier. This is helpful if your domain name is not so far registered or not pointed to a host report, but you want to preview your web site.

Download eBook : Speed Up Your Website. 8 hardheaded Tips That Work
In this tutorial you will learn how to edit the hosts file on Mac. For a tutorial on how to do the lapp on Windows chink here .
Important! note that changes made for the hosts charge will affect your calculator only .

What you’ll need

Before you begin this guide, you ’ ll need the watch :

  • root user privileges

Step 1 – Opening Hosts File

Follow these steps to open your hosts file on Mac :

  1. Access launcher (F4 key) and type in terminal in the search field. Click on the Terminal icon.
    Terminal Icon Mac
  2. We will use Nano text editor to open the hosts file. You can open it with Nano by executing the following command:
    sudo nano /private/etc/hosts
  3. As we use sudo to edit the hosts file, you will be asked to enter the password of your Mac user account. Note that due to security reasons the cursor won’t move. This is normal – simply enter your password and hit the ENTER key.

Step 2 – Editing Hosts File on Mac

In order to emulate DNS change and point sphere name to an IP address, use the keep up syntax :

IP_Address domain.com
IP_Address www.domain.com

For case, to emulate DNS change for hostinger.com and www.hostinger.com we would have to include the surveil lines at the bottom of hosts file .  hostinger.com  www.hostinger.com

This will emulate change IP address of the hostinger.com and www.hostinger.com to .
once you are done with editing hosts file, press CMD + X on your keyboard, figure Y to save changes and hit ENTER button .

Step 3 – Flushing DNS Cache (Optional)

sometimes changes do not apply immediately and you may need to flush the DNS cache. On Mac, DNS cache can be easily flushed by executing the follow dominate :

Mac OS X Snow Leopard

sudo dscacheutil -flushcache

OS X Mavericks, Mountain Lion, and Lion

sudo discoveryutil mdnsflushcache


That ’ s it, by finishing this short tutorial, you have learned how to edit a hosts file on Mac. This is useful if your domain identify is not registered or not pointed to the server, but you want to preview your web site. In addition, you have besides learned how to flush the DNS cache on Mac .

Was this tutorial helpful?

The generator

Domantas G .
Domantas leads the contented and SEO teams forward with fresh ideas and out of the box approaches. Armed with extensive SEO and selling cognition, he aims to spread the word of Hostinger to every corner of the world. During his dislodge time, Domantas likes to hone his web development skills and travel to alien places .

beginning : https://themedipia.com
Category : Website hosting

Leave a Reply

Your email address will not be published.