Host Files For Mac



  1. How to Edit Hosts File on Mac with TextEdit. Another way for editing hosts file on Mac is via apart from using Mac terminal text editor is TextEdit. Navigate to Finder Go Go to Folder Now type /private/etc/hosts and tap on Go. Copy the hosts file on your Mac’s desktop and then double click the file to make changes.
  2. All Mac computers store a small, text based file called 'hosts'. Modifying this file is sometimes necessary to solve connection problems, set your own web server, and instruct the system to block access to specific websites (thus to prevent opening malicious websites).

Fixing hosts file on Mac will help to intervene in the system, help block websites or block browser ads.

File hosts on the system help users to intervene deeply into the computer, support users to change the system such as blocking ads from certain websites or software such as blocking ads on Viber, or blocking websites. browser, even support access to blocked websites, .

File hosts on all operating systems allow users to change, edit, add commands to meet the purpose we want to perform. To edit the hosts file on Mac, users also need to follow each step in the order as when editing the hosts file on Windows 10 or changing the hosts file on Linux. The following article will guide readers to change the hosts file on a Mac.

  1. 5 ways to block websites and limit usage time on Linux computers
  2. How to open the hosts file on Windows
  3. How to reset HOSTS files on Windows 7/8 / 8.1 and Windows 10
  4. How to create a new host file on Windows

Instructions to edit the hosts file for Mac

Method 1: Edit the hosts file on Mac via etc

The Mac hosts file is an important text document on Mac OS X that allows the mapping of hostnames to specified IP address. Even though the Internet has both public and private DNS servers for mapping of IP address, the hosts file on Mac is a good way to override DNS servers.

Step 1:

Where Is The Host File

First we press the key combination Command + Shift + G to display the directory access dialog. Next we enter / etc into the search field and click Go to continue.

Host Files For Mac

Step 2:

Show etc folder with many files inside. Users browse to fie hosts and then double click to open and edit and save.

In case the hosts file does not save, we overwrite the content, the user moved that hosts file to the desktop or another directory to edit. Then copy to the etc directory to overwrite the existing hosts file.

Method 2: Edit the hosts file on the Mac via Terminal

For Mac OS, we have more ways to fix hosts file via Terminal.

Step 1:

Users access to Utilities folder and then click on Terminal in the list to launch. Or we press the keyboard shortcut Commnd + Space and then type the keyword Terminal to open up.

Step 2:

In the interface shown, enter the command sudo nano / private / etc / hosts and then type the password of the Mac into the Password line below. Click Return to open the hosts file.

Step 3:

Display the hosts file interface for users to edit. We use the left and right up and down arrows to move the cursor to where the content of the hosts file needs to be edited.

Step 3:

Once finished editing, we press Ctrl + X and then press Y to agree to save new content to the hosts file. Finally press Return to agree or press N to not save the content.

So we have 2 different ways to edit the hosts file, change the content of the hosts file on the Mac. If you edit the hosts file via etc, it is best to copy the file to another location for editing and then copy the etc folder again to overwrite the existing file.

I wish you successful implementation!

READ NEXT»

I use my Mac to surf the Internet all the time. However, my Internet experience is becoming too difficult. My browser’s performance is failing and right now, I hate to surf the Internet using my Mac. It’s just too frustrating. They said I could edit the Mac hosts file to fix this. How do I do it? ~Internet Surfer/ Mac User.

Part I: Introduction

Let’s start with domain name servers (DNS) first. A DNS is used to match domain names (for human consumption) to that of IPv4 and IPv6 addresses (for machines). It’s the Internet’s version of a phone book.

DNS is very important to the Internet. However, it is not the only method of connecting IP addresses with that of domain names. Hosts files can also be used to connect mind-boggling IP addresses with domain names meaningful to humans. A hosts file is actually an ASCII text file that can be used by most operating systems to connect IP addresses and domain names.

Part II: How to Edit the Host File Automatically?

Mac Hosts File Wildcard

When you edit your host file it is similar to modifying a specific phone book contact’s number. If you input the wrong name (but have the correct number), you’re still going to be routed to the person when you call him/ her. But if you have inputted the wrong number, you won’t be able to get to that person’s phone whether it connects to somebody else or it connects to an invalid number.

When you edit the host file, you are actually rerouting the IP address. However, you are doing this only from your device. When you enter a particular web address, you will be routed to a different IP address (an address that you choose) OR you will be routed to an invalid IP. The latter will display on your browser as an error page stating that it cannot find the site you have entered.

Fortunately, when you edit the hosts file, you can help boost the performance of your browsers. However, if you want a real full boost, it is recommended that you do a complete cleanup of your browser. You should erase your browser cache as well. One tool you can use to do this is iMyMac’s Browser Cleaner.

Edit Host File

Here’s a step-by-step guide on how to use it:

Step 1 – Download iMyMac – Cleaner from https://www.imymac.com/
Step 2 – Launch the program. It will show you the system status of your Mac on the main interface.
Step 3 – On the left side of the window, select “Browser Cleanup.”
Step 4 – Click “Scan.” The scanning process will start, you have to wait for a few minutes.
Step 5 – Once the scan is complete, you can choose your desired browser.
Step 6 – After which, select the category you want to delete. These categories include Visit History, Downloads History, Downloaded Files, Search History, Cookies, Login History, and Auto Fill History, among others.
Step 7 – Click the “Clean” button and wait for the process to be finished.
Step 8 – Repeat the process for other browsers (from Step 5 to finish).

Part III: How to Edit the Hosts File Manually?

Method 1- Using the Terminal

In order to edit the hosts file with the Terminal, administrator privileges is required. You also need the password.

Here’s how to do it step-by-step:

Step 1 – Search for the Terminal app on your Mac. You can do this by utilizing the Spotlight application. Or, you can choose Applications located within the Finder window’s sidebar. Next, choose Utilities and select Terminal.

Step 2 – When the Terminal windows has launched, you have to be able to access the Nano text editor which is used for editing the hosts file. You have to input sudo nano/etc/hosts and press Enter. It will ask for an administrator password. Enter your admin password and press Enter one more time. Now, you will be inside the Nano text editor.

Step 3 – Put your cursor below the text already included in the Nano text editor. This is where you’ll actually input the alternative IP address. Input the specific IP address you wish the website to be rerouted to. Press Tab. After which, input the domain name you wish to associate with it. For example, if you want Facebook to reroute back to your homepage, just input your site’s IP address, press Tab, and then input www.Facebook.com. To enter another website/ entry, just add a new line.

If you don’t have any thoughts with regards to an alternative site or if you want to completely block the site, you can input invalid IP addresses. Or, you can utilize 127.0.01 which always reroutes to your system.

Hosts

Step 4 – Save the modifications you have made by hitting Control + O. Now, close the Nano text editor by hitting Control + X. This will put you back on the Terminal screen.

Step 5 – To ensure Mac doesn’t experience confusion due to the conflicting info from both the DNS and the hosts file, you should input sudo killall -HUP mDNSResponder before you close command line. Then, press Return. With this action, you are deleting the DNS cache. Thus, the old directory will run in conflict with the newly modified hosts file.

Method 2 – Using TextEdit

Step 1 – Go to Finder. Click Go and then click Go To Folder. After which, input /private/etc/hosts and hit Go.

Step 2 – Copy the said file onto your Mac’s desktop. Open the file for editing. In the text file that launches, input your alternative address similar to that of what you’ve done in the Terminal: First, place the rerouted IP address and then the domain name. Ensure that there’s a space in between the domain name and the IP address to make it work.

If you wish for your Mac to remove access to particular websites, you can utilize 127.0.01 as an IP address. This will reroute the address to that of your Mac.

Host File Format

Note: Sometimes on OS X 10.11 and above, the file will be locked. Thus, you will not be able to edit it. What you need to do is to disable SIP protection before modifications can be made.

Mac Hosts File Not Working

Step 3 – Save the file you have edited. After which, put it back to the folder name “etc.” Mac will confirm if you want to replace the said file. Confirm the replacement and then input the administrator password to save it.

Part IV: Why Edit the Hosts File?

File

If you wish to enter a web address in your browser, it’s for the reason of wanting to reach a particular IP address. So why do you need to edit the hosts file? Why do you need to reroute? Here are the benefits of doing so:

1 – Testing Networks

If you are trying to develop a specific network, you can actually reroute the real domain name to that of the development website. The reason for doing so is to check out how real users would experience the site. The good thing about it is it will not, in any way, affect the users who are trying to access the real site.

2 – For Blocking Malicious Websites

There are risks of malware and viruses. Plus, sneaky add-ons can “sneak” their way within your system and this results in slowing down of particular things. You can use pop-up blockers to block malicious sites. However, when you edit the hosts file, it actually helps you prevent access to malicious sites. If a certain pop-up or link tries to enter the malicious site, your operating system will just re-route and launch another safer web page.

3 – For Increasing Speed

When you use the DNS to find a webpage, it is slower compared to using a host’s file. When hosts files are localized to a Mac, the middleman is eliminated and it speeds up the browsing experience.

Host file on mac

Host Files Mac Location

4 – For Enhanced Productivity

Social media networks and streaming of videos can be distracting. You can block access to these sites to improve team or company productivity.

Part V: Risks of Editing Hosts Files

By editing the hosts file, you are rerouting a specific domain to a specific IP address which is not actually a site. Thus, if you have edited the hosts file to set a particular domain to another website, it will be dependent on the IP address staying the same as the ones you have inputted.

If the website it is rerouted to modifies its own IP address, the new route you have made will be invalid. The domain name will either show up a new site or show an error message. If your servers are taking too much time when processing the requests, the DNS lookup might NOT be the one slowing the process. You should try to completely clean your operating system to make sure your Mac is not causing the problem.

Part VI: Other Way to protect your macOS Privacy

Solutions to protect your privacy in a macOS are easy to do. One solution is to clean your Mac by cleaning your user cache, system cache, and browser cache. You can use the tool called iMyMac’s Mac Cleaner to do the job.

Step 1 – Download iMyMac – Cleaner
Step 2 – Launch the program which will direct you to a main interface with your Mac’s system status.
Step 3 – Click “Junk Files.”
Step 4 – Click “Scan.” iMyMac will show you scanned junk files in various classifications
Step 5 – Select a classification and select the data you want to delete.
Step 6 – Click “Clean” and confirm the process
Step 7 – The process is done and shows Zero KB in some folders.
Step 8 – Repeat the process. But this time, select “Clutter” OR “Large & Old Files” instead of “Junk Files.”

Part VII: Conclusion

Editing the hosts file is one way to improve browser experience. You might think doing the task can be daunting. But it’s actually easy. Just follow our guide above. In all cases, you should clean your browser before editing the hosts file. You can do this by using iMyMac’s Browser Cleanup tool. The said tool is 100% secure and will clean your browser and make it junk free.