Your Mac hosts file is crucial for a number of reasons. however, it ’ s peculiarly crucial when you want to override your Domain appoint System ( DNS ) and map to a new Internet Protocol ( IP ) address. In that scenario, it ’ south essential to know how to locate and access this file .
See how Kinsta stacks up against the competition .
The estimable news is that doing so is relatively quick and painless. You simply need to know which application to use and what commands to run. then you can safely edit and update your hosts file to resolve domain names to IP addresses on your Mac device.

In this post, we ’ ll explain what the Mac hosts file is and the purpose it serves. then we ’ ll walk you through how to find and edit it in four elementary steps. Let ’ s jump right in !

What the Mac Hosts File Is (and Why It’s Important)

typically, your web site is found using the DNS in the nameservers your sphere is pointed to. The DNS translates your URL ( such as ) into an IP address that the waiter can interpret .
however, your calculator ( in this sheath, a Mac ) can use the hosts file to resolve your web site to a unlike or specific IP address. In other words, you can manually configure your domain name to the IP address of your choose .
For example, one of the reasons you may want to edit your hosts charge is because you ’ re in the process of migrating your web site to a new server .
manually editing your hosts file to resolve the IP address and world mention will let you test your site on a unlike server. This rule applies even when the DNS hasn ’ thymine propagated yet .
In a nutshell, you can use your Mac hosts file to mimic and test everything. As such, you can ensure that all seems to look and function appropriately before you complete the migration process .
Your Mac hosts file is crucial when you want to override your DNS and map to a raw IP address … and to do that, you need to know how to locate and access it. 👩‍💻Click to Tweet

How To Find and Edit Your Mac Hosts File (In 4 Steps)

now that you understand a little more about the Mac hosts file, it ’ randomness fourth dimension to get to work. Below is how you can locate and edit this charge in four easily steps .

Step 1: Open Your Terminal Application

To get started, you ’ ll first need to access and open your Terminal application. besides, note that you ’ ll need root drug user privileges to do this. If you don ’ t have these privileges, you can log in with an administrator account and enable the beginning user score .
You can find the Terminal application by navigating to Finder > Go > Utilities.
Find the Terminal application on your Mac
Doing this will bring up versatile tools that you can use to control your Mac device. following, snap on the  Terminal application .
Select the Terminal application in Utilities
alternatively, you can besides hit F4 to open the catapult. then type “ terminal ” in the search playing field, and select the Terminal picture when it appears .

Step 2: Access Your /etc/hosts Folder

once the Terminal application opens, you ’ ll need to use a text editor program in order to access the hosts file. We ’ ll use the Nano text editor for this tutorial because it ’ south versatile and user-friendly .
start by installing the newest version of the Nano program. You can then enter the following command into the Terminal application .

sudo nano /etc/hosts

next, press your Enter/Return key. You ’ ll then be asked to type in your administrator password :
Enter the sudo nano /etc/hosts command
character in your password and hit the  Enter/Return key once again.

Sign Up For the Newsletter

Want to know how we increased our traffic over 1000%?

Join 20,000+ others who get our weekly newsletter with insider WordPress tips !

Subscribe Now


eminence that when you enter your password, it won ’ deoxythymidine monophosphate populate on the screen for security system purposes .

Step 3: Begin Editing Your Mac Hosts File

After you type in your password and reach Enter/Return, you ’ ll be brought to the Nano text editor. At this point, your riddle should look like this .
The Nano Text Editor
The follow steps will depend on what precisely you ’ re planning to do within the hosts file. however, let ’ s think that you ’ re trying to add a new domain .
You can use your arrow keys to navigate to the bottom of the file. then, on a new credit line, you can add the IP address of the domain you want to add :
Add the ip address of the domain
As you can see from the above screenshot, we added “ ” as our modern knowledge domain. You will want to replace this, arsenic well as “, ” with whatever you ’ re trying to add .
besides, keep in take care that every entry you add should have its own argumentation. For model, multiple entries should be in the follow format : Tired of subpar level 1 WordPress hosting support without the answers ? Try our first support team ! Check out our plans


If you want to cancel the changes you ’ ra make, you can use your keyboard to delete the cable ( s ) you ’ ve added. You can find a key menu list at the penetrate of the editor window .
In accession to adding IP addresses, you can besides block them to prevent your device from pointing a web site their means. For that, you can use “ ” .
When you ’ re done, you can press Ctrl + O to overwrite the existing file, followed by the Enter/Return key. You can exit by using Ctrl + X .

Step 4: Flush Your DNS Cache

If you ’ ve edited your Mac hosts file, but your changes aren ’ thyroxine going bouncy, the trouble may be with your DNS cache. consequently, it ’ s not a bad estimate to flush your cache when you finish editing the charge .
Flushing your cache removes saved IP records. As such, this process will enable your browser to reflect the update IP address from the edit hosts file .
To update your browser DNS records, you can enter the postdate instruction into the Terminal application :

sudo killall -HUP mDNSResponder

This step will ensure that your changes go live within your browser. You ’ ve nowadays successfully edited your Mac hosts file !
Learn how to find and edit the Mac hosts file four simple steps. 💪Click to Tweet


Migrating your web site to a raw server can be a major job. Using a hosting provider such as Kinsta makes it a simple process. however, there may be situations when you want to mimic and test the site on your new server before completing the migration action. When that ’ s the character, you can do so via your Mac ’ mho hosts file .
As we discussed in this station, you can find and edit your Mac hosts file by following these four childlike steps :

  1. Open the Terminal application on your Mac computer.
  2. Access your /etc/hosts folder using a text editor such as Nano.
  3. Begin editing your hosts file to add the new IP addresses and domain names.
  4. Flush your DNS cache to apply the changes to your browser.

There are many advantages to manually editing your Mac hosts file. however, did you know that when you host your site with Kinsta, we provide seamless migration services adenine well as a irregular URL for testing purposes ? Check out our plans today to learn more !
Save meter, costs and maximize site performance with :

  • Instant help from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audience reach with 32 data centers worldwide.
  • Optimization with our built-in Application Performance Monitoring.

All of that and much more, in one design with no long-run contracts, assisted migrations, and a 30-day-money-back-guarantee. Check out our plans or talk to sales to find the design that ’ s right for you .

beginning :
Category : Website hosting

Leave a Reply

Your email address will not be published.