macOS Catalina gives you more of everything you love about Mac. Experience three all-new media apps: Apple Music, Apple TV, and Apple Podcasts. Locate a missing Mac with the new Find My app. And now coming to Mac, your favorite iPad apps. You can even extend your desktop using iPad as a second displ. Apr 15, 2020 This article was co-authored by our trained team of editors and researchers who validated it for accuracy and comprehensiveness. WikiHow's Content Management Team carefully monitors the work from our editorial staff to ensure that each article is backed by trusted research and meets our high quality standards. The wikiHow Tech Team also followed the article's instructions and verified that.
System cleanup in one click
Make your Mac fast and secure with CleanMyMac X.
If you use your Mac every day, you know how seamless and intuitive the experience can be. It’s almost akin to play: dragging and dropping icons and files, and having the whole environment neatly arranged.
Despite the apparent ease of use, Macs are highly capable machines that could really open up their programmatic side and let you control them right from your keyboard. All this is because macOS is based on the Unix system, just like Linux and many others that are known for providing much greater levels of control compared to more closed systems, such as Windows.
Control over Mac’s performance with Setapp
And that’s only part of what Setapp does for you. A single toolkit with 180+ apps enables your macOS to work seamlessly.
Why is having a more open system such a big deal? Simply, controlling macOS programmatically speeds up lots of everyday tasks and reveals lots of functionality that is otherwise completely inaccessible through a regular graphic interface. You might have even already used the key Unix-like tool in your Mac’s arsenal — Terminal.
Terminal allows you to perform nearly every function you normally use your mouse for: navigate folders, change preferences and settings, execute commands, etc. One of the unique tasks that can be easily controlled through Terminal is configuring your Mac’s Hosts file.
What And Where Is Hosts File On Mac
Hosts file is a hidden gem on your Mac that lets you override DNS settings exactly as specified. Let’s elaborate. Any website on the internet has a standard numeric TCP/IP address (e.g. 155.135.55.81) — that’s how your browser is actually able to find the website you want. However, no one would ever want to remember all those TCP/IP numbers, and that’s why the Domain Management System (DNS) was created.
Every time you put in a URL in your browser (e.g. setapp.com), it pings the domain server, which in turn translates the requested domain into the TCP/IP format, and only then connects as to be able to display it.
Having said that, there are instances when you don’t want the domain name to go to the actual TCP/IP, but would much rather write down your own. This can be necessary when you want to test a new website you’re developing locally, or a new development server altogether. You can also use Hosts file on Mac to block adware and spyware websites, and even some time-wasting ones (e.g. social media).
Now let’s discover how we can actually change Hosts file on Mac.
How to edit Hosts file on Mac
To edit Hosts file Mac features is not a difficult although completely non-obvious process. To open Hosts file on Mac, which is hidden, you need to use Terminal:
Now you’ll notice you’re in the Nano text editor, from where you can actually edit Mac’s Hosts file. As you can see, some of the TCP/IP addresses are already reflected in here against localhost and broadcasthost titles. All you need to do to input your own TCP/IP is to follow the same format:
The changes should take effect immediately. Using the Mac Hosts file this way you can literally input any TCP/IP you need, from other websites to your own development server to your Mac (just type in 127.0.0.1), which can be useful when you want to avoid using social media or other distractions. You could also outright block malicious websites with a 0.0.0.0 address.
When adding multiple entries, make sure each one has its own line. To cancel the change, repeat the process above but simply delete the line you’ve added before that is no longer needed.
Fix a malfunctioning Mac Hosts file
Sometimes when you add too many entries to your Hosts file Mac might not process them correctly. It could be that some of the TCP/IP addresses are responding to the same domain name or you’ve deleted some other essential information.
To resolve the situation, you could try following the instructions above to get to the Nano text editor and then delete everything there and retype the default configuration:
##
# Host Database
#
#
# localhost is used to configure the lookback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255broadcasthost
::1localhost
While this might or might not work, there is a better preventative way of making sure you don’t end up somehow crushing your system — creating consistent backups.
Keep your files safe with Disk Drill
No chance you can damage your system. With Disk Drill, you’ll be able to instantly schedule backups and recover files.
Disk Drill is the top-rated data recovery and backup tool. It lets you effortlessly back up files to any external drive, so you always have a copy of your information on hand.
If you don’t have enough space on your external disk to duplicate your hard drive and just want to protect your Mac Hosts file, you can simply duplicate it in its original state, before making any changes.
To locate the Hosts file on Mac:
You should end up within the 'etc' folder and have the Mac Hosts file highlighted. Just copy the document onto an external hard drive using Disk Drill and then you can confidently experiment with the Hosts file without the fear of breaking anything.
If however the problem has already occurred, Disk Drill can try to recover your file using its recovery mode. To give it a try, launch Disk Drill and click Recover next to your Macintosh HD.
Protect your daily internet presence
When your sole purpose for tinkering with the Hosts file on Mac is being haunted by adware, spyware, or something of that type — relax — there’s a much better way to get rid of those intruders.
Secure Mac against any issues with CMM X
Detect and remove malware or get rid of caches, CleanMyMac X will help you solve every Mac problem in minutes.
CleanMyMac X is an all-in-one optimization utility that easily detects and deletes malware from your Mac. Just select Malware Removal scan from the sidebar and CleanMyMac X would find any malicious files on your computer in seconds.
Besides, CleanMyMac X makes it easy to flush DNS cache (without using Terminal), as well as clear browser cache, run maintenance scripts, and effortlessly keep your Mac in top shape overall. Just start with a quick Smart Scan and every now and then go through a variety of optimization tests, which are located in the sidebar, and simply follow the instructions.
As you can see, you have a few options to find and edit Mac’s Hosts file. Feel free to follow the guide above and experiment with various TCP/IP settings to check your development server or block undesired websites.
Also remember that not everything has to be done through the Mac Hosts file. In fact, treat it as the last resort and try to rely more on using intuitive software like CleanMyMac X when it comes to optimizing your browser and removing malware. And if you absolutely have to use the Hosts file, make sure you properly back up your Mac with Disk Drill, so you can recover your Hosts file if things go awry.
Best of all, you can try both CleanMyMac X and Disk Drill for free through Setapp, a widely popular Mac platform with more than 150 apps across dozens of categories. Now that you’ve been warned and prepared, go get your Hacker Mode on!
What is hosts file and how does it differ from DNS?
First of all, what is the hosts file, and how does it differ from the more commonly known DNS?
The Domain Name System is the database that corresponds an IP address’ “dotted quad” numerical format with a website’s alphabetized web address. It’s a giant directory of which name belongs to which IP address, like an online yellow pages.
Your Mac’s hosts file, however, is localized to your own device, like a list of contacts in your phone: The web address acts as your contact’s name — that’s how you find who you want to talk to — and the IP address is their cell phone number, which is your actual way of getting in touch with them.
How editing the hosts file works
Editing your Mac hosts file is a bit like changing the phone number in your contact book. If you save the contact details with the wrong name, well, it’s still going to connect to that person when you ring the contact. If, however, you entered an incorrect phone number in our contacts analogy, whether that’s an invalid number or one that links to someone else’s, then you have no chance of getting through to that particular cell phone.
Editing the hosts file reroutes the IP address, but only from your own Mac. Entering the web address will bounce you to a different IP address of your choosing (and therefore a different website) or to an invalid IP, which will give you an error page on your browser that says it can’t find the site you’re looking for.
Can it boost my Mac's speed?
Editing a hosts file is a way to speed up your browser performance. But if you're tired of half-measures and want some solid improvement, we recommend a full browser cleanup, including deletion of browser cache. Our personal favorite is CleanMyMac as it has a tool to uninstall browser extensions and the rest of the garbage Macs accumulate from the web, emails and message chats. Check it out — it's available for a free download here.
So why would you want to change your hosts file?
Typically if you enter a web address in your browser, it’s because you want to reach that IP address. So what are the benefits of rerouting?
How to edit the hosts file with Terminal
Note: You will need administrator privileges, including the password, to edit the Mac hosts file.
1) Find the Terminal application on your system. You can do this by either:
- Use the Spotlight application to search for it.
- Select Applications from the sidebar of a Finder window, and from there select Utilities and then double-click on Terminal.
2) Once you have the Terminal window open, you can access the Nano text editor, which is where you will edit the hosts file. Type sudo nano /etc/hostsand hit Enter. You’ll then be prompted for your administrator password. Once you’ve entered it, hit Enter again and you will be in the Nano text editor.
The Nano text editor might look intimidating if you’re not used to coding on your OS, but don’t worry: it’s very simple, and very easy to do.
3) Use your keyboard arrow keys to position your cursor beneath the text that is already there. This is where you’re going to enter your alternative IP address. Type the IP address that you want the site to reroute to, hit tab, and then type the domain name you want to be associated with it. So, if you would prefer that YouTube reroutes to your homepage, simply type the numerical IP address of your site, hit Tab, and then type www.youtube.com. To add another entry, simply enter a new line of text.
If you have no particular alternative site in mind, or you simply want to block access to it entirely, you can either enter an invalid IP address, such as 000.0.0.100, or use 127.0.01, which always refers back to your own system.
4) Save the changes by pressing control and O, and then exit the Nano text editor by pressing control and X, which will return you to the main Terminal screen.
5) To make sure your Mac doesn’t get confused by the conflicting information from its hosts file and the DNS, before you exit the command line type sudo killall -HUP mDNSResponderand hit Return. This clears your Mac’s DNS caches so that the old directory doesn’t conflict with your newly updated hosts file.
How to edit the hosts file with TextEdit
An alternative to the Terminal application is to use TextEdit instead.
Mac Os X Host File App List
1) Click Finder > Go > Go to Folder...
Then type /private/etc/hosts and press Go. This will locate the hosts file in the ‘etc’ folder.
2) Copy the file onto your desktop, and then double-click the copied file to edit it. In the open text file, add your line of alternative IP addresses just as you would in Terminal: First the rerouted IP address and then the corresponding domain name. Make sure that there is a space between the IP address and the domain name, otherwise it won't work.
If you don't want your Mac to access certain websites, use 127.0.0.1 for IP address. This will reroute the address back to your Mac. For example, if I wanted to block the access to Facebook on a particular Mac, I would edit hosts file to look like this:
Note: If the file is locked to prevent you from editing it, which is likely if you’re running on OS X 10.11 or later, you must disable SIP protection before you can make any changes.
3) Save the file, and then drag it back into the ‘etc’ folder. Your Mac will ask if you want to replace the file, which you do, and you will have to enter your administrator password to save the changes.
Mac Os X Host File App Windows 7
Remember, even if you own the domain name you are rerouting, the web address itself will not be affected. The hosts file only changes what happens on the Mac that contains it.
The risks of editing hosts file
Remember, you’re rerouting a domain to an IP address, not specifically a website. So if you have set one domain to be sent to another site, this depends on the IP address staying the same. If the destination website changes its IP address, your new route will no longer be valid, with the domain either ending up in a new website or producing an error message.
If your server is still taking too long to process requests, it may not be the DNS lookup that is slowing you down. It might be worth running a full clean of your OS to make sure the lag isn’t coming from your Mac.
How else you can protect privacy on your macOS
Anyone reading this is concerned enough about privacy and security to want to find a solution. As we’ve outlined in this article, there are several ways this can be done manually. Some of these fixes take time. Other solutions are fairly quick and easy to implement.
With CleanMyMac X, you can clean your system cache, user cache (which includes app and DNS cache history) and your browser cache. Of course, there is the manual way, as outlined in this article, or you can save a lot of time with one download and a few clicks to remove any digital footprints you want to delete.
If you want to clear cache safely and easily, here is how you can with CleanMyMac X:
In case you need to remove just DNS cache, do the following:
Mac Os X Host File App Windows 10
Done! Your DNS cache flushed.
That’s all you need to do. Give it a try, or go through the steps outlined above to do this manually.
Mac Os X 10.11 DownloadThese might also interest you:Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |