Your Mac host file is important for several reasons. However, it is especially crucial when you want to replace your domain name system (DNS) and MAPEU -BOOD to a new Internet Protocol address (IP). In this scenario, it is essential to know how to locate and access this file.
The good news is that it is relatively fast and painless. You just need to know what application you should use and what orders will be run. You can then edit and update the hosts to resolve domain names in the MAC device IP addresses.
This post explains what the Mac Host file is and the purpose it serves. He then directs you to find it and edit it in four simple steps. Jump directly!
What is the Mac Host file (and why is important)
Usually your website is found by DNS on name servers in your domain. DNS translates your URL (such as kinsta.com) in an IP address that the server can interpret.
However, your computer (in this case, a Mac) may use the hosts to resolve your site to a different or specific IP address. In other words, you can manually configure your domain name to the IP address you choose.
For example, one of the reasons why you may want to edit the host file is because you are in the process of migrating your website to a new server.
The manual edition of the hosts file to solve the IP address and the domain name will allow you to try your site on a different server. This rule applies even when DNS has not yet spread.
In a nutshell, you can use your MAC Hosts file to imitate and try everything. As such, you can ensure that they all seem to look and function properly before completing the migration process.
How to find and edit Mac’s host file
Now that you understand a little more about the MAC hosts file, it’s time to start working. It is then shown how you can locate and edit this file in four easy steps.
1. Open your terminal application
To begin with, you must first access and open the terminal application. Note that you will need the root user privileges to do If you do not have these privileges, you can log in with an administrator account and activate the root user account.
You can find the terminal application by browsing a Ceilter > Go > Utilities.

If you do, you will raise several tools you can use to control the MAC device. Then click the terminal application.

Alternatively, you can also hit F To open the pitcher. Then type “terminal” in the search field and select the Terminal Icon when it appears.
2. Access the /etc /host folder
Once the terminal application is opened, you can find the hosts file in the /etc/hosts
Folder. But to access it, you must use a text publisher. We use the nano text publisher for this tutorial because it is versatile and easy to use.
It begins by installing the most recent version of the Nano program. You can then enter the following order in the terminal application.
sudo nano /etc/hosts
Then press your Enter/Return Key. You will then be asked to write the administrator’s password:

Type your password and click on the Enter/Return key once again.
3. Start editing the MAC host file
After writing the password and hitting -la Enter/ReturnYou will be at Nano Text Editor. At this point, the screen should look like that.

The following steps will depend on what you plan to do in the host file. However, let’s imagine you try to add a new domain.
You can use the arrow keys to navigate to the bottom of the file. Then in a new line you can add the IP address of the domain you want to add:

As you can see at the previous screen capture, we added “123.123.123.123” as our new domain. You want to replace it, as well as “MyDomain.com”, for all you try to add.
Also keep in mind that every entry you add should have their own line. For example, several entries should be in the following format:
SERVER_IP_ADDRESS domain.com
SERVER_IP_ADDRESS www.domain.com
If you want to cancel the changes you make, you can use the keyboard to remove the lines you have added. You can find a list of key menus at the bottom of the publisher’s window.
In addition to adding IP addresses, you can also block them to prevent your device from pointing out a place on your way. That is why you can use “127.0.1”.
When you have finished you can press CTRL + O to overwrite the existing file, followed by Enter/Return Key. You can leave by use Ctrl + x.
4. Wash DNS cache
If you have edited the Mac host file, but the changes will not be live, the problem may be with the DNS cache. Therefore, it is not a bad idea to drag the cache when you have just edited the file.
Remove cache removes saved IP records. As such, this process will allow your browser to reflect the updated IP address of the edited hosts file.
To update the browser DNS records, you can enter the following order in the terminal application:
sudo killall -HUP mDNSResponder
This step will ensure that your changes are made live inside the browser. Now you have successfully edited the MAC host file.
Summary
Migrating your website to a new server can be an important task. The use of a accommodation supplier like Kinsta makes it a simple process. However, there may be situations where you want to imitate and try the place on your new server before completing the migration process. When so, you can do it through your Mac’s host file.
As we mentioned in this post, you can find and edit the MAC host file following these four simple steps:
- Open the terminal app on your MAC computer.
- Access the /etc /host folder through a text publisher like Nano.
- Start editing the host file to add new IP addresses and domain names.
- Wash DNS cache to apply changes to browser.
There are many advantages to manually edit the MAC hosts file. However, do you know that when you host your site with Kinsta, do we provide perfect migration services and a temporary URL for test purposes? Check out our plans today for more information.