Do you want to edit the Mac host file? While setting up the latest web server or another device that’s going to be plugged to the internet and you want to put it through its speed before it’s live. Or else if you’re facing issues with adware or spyware networks. Then there’s an invisible file on Mac that helps. It is known as the Hosts file, and this is how to use it.
The Domain Name System
Input the domain name of a web site. Every service or web site, almost every device plugged to the Internet has a unique numeric address. The address tells all the other devices where it is — its TCP/IP address. However, the Domain Name System (DNS) interprets numeric addresses into something a bit more memorable or recognizable to humans. Like “www.imore.com” etc.
Initially, once you input a web address, your Mac pings a DNS server. Typically one configured automatically for you by your ISP (Internet Service Provider) just to find out the TCP/IP address of the server you’re trying to connect to. However, your Mac builds up a hidden cache file to make sure that those details later on after you visit the same site again.
The Hosts file
The Domain Name System and its linked cache is your Mac’s way of knowing how to get to where it’s going on the Internet. But there’s an alternative file that can be very essential. It is known as the Hosts file, and it can also be used to override the default DNS information.
There are some practical causes why you’d like to use the Hosts file rather than of just allowing DNS to do its thing. Let’s say you’re checking a development server you’re about to install. Also, you want to use its domain name rather than the machine’s particular IP address. Before the PCs online and accessible to anyone via DNS. You can then use the Host file. Simply enter the machine’s IP address and while using that domain name, your Mac will move to that device.
Also, you can use the Hosts file to work around or block spyware and ad networks after “zeroing out” their IP addresses. Just put 0.0.0.0 then the name of the domain you would like to block.
Edit Mac Host File Manually
Fix 1 – Using Terminal
If you want to edit the host’s file with the Terminal, administrator rights are required. You also want the password.
Look for the Terminal app on your Mac. For this utilize the Spotlight application. Or, you can select Applications located within the Finder window’s sidebar. Then, select Utilities and choose Terminal.
Once you launch the Terminal windows, you can access the Nano text editor that is used for editing the host’s file. Simply input sudo nano/etc/hosts and hit Enter. It’ll ask for an administrator password. Just input your admin password and hit Enter one more time. Now, you will enter the Nano text editor.
Add your pointer below the text already added to the Nano text editor. This is where you’ll actually enter the other IP address. Enter the particular IP address you want the website to be rerouted to. Hit Tab. After that, enter the domain name you want to link with it. For instance, if you want Facebook to reroute back to your homepage, simply input your web site’s IP address, hit Tab, and then enter www.Facebook.com. If you want to input another website/ entry, just add a new line.
If you want to fully block the site, you can enter invalid IP addresses. Or else you can utilize 127.0.01 which always reroutes to your PC.
Save the changes you have made by pressing Control + O. Now, exit the Nano text editor by pressing Control + X. This will put you back on the Terminal display.
If you want to know that Mac doesn’t experience confusion because of the conflicting info from both the DNS and the host’s file. Then you simply enter sudo killall -HUP mDNSResponder before you exit the command line. Then, hit Return. With this action, you are removing the DNS cache. Thus, the old directory will execute in conflict with the newly modified hosts file.
Fix 2 – Using TextEdit
Head over to Finder. Tap Go and then tap Go To Folder. After which, input /private/etc/hosts and press Go.
Copy the required file onto your Mac’s desktop. Then open the file for editing. In the text file enter your alternative address identical to that of what you’ve done in the Terminal: Initially, put the rerouted IP address and then the domain name. Remember that there’s a space in between the domain name and the IP address to make it work perfectly.
If you want your Mac to erase access to specific websites, you can then utilize 127.0.01 as an IP address. As it will reroute the address to that of your Mac.
In this step simply save the file you have edited. After that, add it back to the folder name “etc.” Mac will confirm if you like to replace the required file. Confirm the replacement and then enter the administrator password to save it.
Reasons To Add The Host File:
If you want to input a web address in your browser, then you want to reach a specific IP address. So why do you want to edit the host’s file? Here are the advantages of doing so:
If you want to develop a particular network, you can then reroute the real domain name to that of the website. The main cause behind this is to check out how real users can experience the site. The best thing about it is it can’t affect the users who can access the real site.
Blocking Harmful Websites
We all know the risks of malware and viruses. Also, clever add-ons can “sneak” their way within your PC and this results in slowing down of some things. You can simply use pop-up blockers to block harmful sites. However, after you edit the host’s file, it helps you to secure access to harmful sites. If a particular pop-up or link wants to enter the harmful site, your OS will re-route and launch another safer web page.
After using the DNS to find a webpage, it is slower as compared to using a host’s file. When host files are localized to a Mac then it becomes faster in speed.
Social media networks and video streaming can be disturbing. You can also block access to these sites to improve the productivity of your company or team members.
After editing the host’s file, you are rerouting a particular domain to a specific IP address that’s not actually a site. Thus, if you want to edit the host’s file to set a specific domain to another website. Then it depends on the IP address staying the same as the ones you have entered.
When the website is rerouted to changes its own IP address, the new route becomes invalid. The domain name will either display up a new site or display an error message. If your servers are taking too much time while processing the requests. Then the DNS lookup probably NOT be the one slowing the process. You just try to fully wipe your OS to ensure your Mac is not causing the issue.
Alternative Way To Secure Your MacOS Privacy
Many fixes to secure your privacy in a macOS are simple or easy to do. One fix is to clean your Mac after wiping your user cache, browser cache, and system cache. You can also use the tool known as iMyMac’s Mac Cleaner to do the job.
Initially, download or install iMyMac – Cleaner
Once installed then launch the program which directs you to the main interface using your Mac’s system status.
Tap “Junk Files.”
Tap “Scan.” iMyMac will display you scanned junk files in different classifications
Choose a classification and pick the data you like to delete.
Tap “Clean” and confirm the process
However, the process is done and displays a Zero KB in some folders.
Repeat the whole process. But this time, choose “Clutter” OR “Large & Old Files” rather than “Junk Files.”