Now that it is open we can edit it to redirect Facebook into nothing. You will notice that with Ubuntu there is also a section for IP6.
For most needs you will only need to edit it the top section and ignore the IP6. Now we can save the file and try to go to Facebook. Just like in windows we will see that we are now redirected to a site that does not exist. In macOS, accessing the hosts file is very similar to Ubuntu.
The file might be corrupted/damaged, it has to be an ASCII file. You should recreate it: move the old file with mv -f /etc/hosts /etc/oldhosts; create. /private/etc/hosts seems to be working normally for me in Yosemite (version ). It's not necessary to flush the cache or reset discoveryd.
Begin in terminal and use your favorite editor, even is you wish to call a GUI text editor, it is easier to do so from terminal. The file will look a bit more like Windows, only with a little less explanation.
Again we are going to redirect Facebook. This time it seems that 0. There are some things to note from this walkthrough that we did notice. When tested it, Chrome did not use the hosts file in any operating system but we were able to block Facebook in Chrome by adding www. Also, make sure to place and extra line after the last entry for the section.
This should get you started in understanding the Hosts file and how it can help protect your computer. If you have more suggestions for any of the operating systems we coved, then leave a comment and let us know! The Best Tech Newsletter Anywhere. Join , subscribers and get a daily digest of news, comics, trivia, reviews, and more.
The IPs were the same both ways. This is mega complicated — I need help here. Turned out my issues were unrelated I'll open a separate issue. Hey Team Great help, any ideas on how I should edit the file so I can view the https? Thanks for the help. The hosts file modification is best as it will require no configuration modification on the site if it will be using the same domain name. If you use your Mac every day, you know how seamless and intuitive the experience can be.
Windows Mac iPhone Android. Smarthome Office Security Linux.
The Best Tech Newsletter Anywhere Join , subscribers and get a daily digest of news, geek trivia, and our feature articles. Skip to content. It is made up of lines of text identifying a numeric IP address and the corresponding host name. For example, this entry.
Your computer would use this information to directly navigate to the site without requiring a DNS lookup. Where the file is located in the file system hierarchy is, however, dependent on the computing platform. Since it is a text file, you can essentially use any text editor to make modifications. For the purposes of this demonstration, we will use the nano text editor that is included with macOS Sierra and later versions. Help on using nano can be found here. Host Database localhost is used to configure the loopback interface when the system is booting. Do not change this entry.
If you intend to make changes to your hosts file, we suggest that you first make a copy of it to revert to if necessary. Take special note of the localhost entry and the IP address of This is the loopback address. Using this address simply returns control to the local machine. This essentially blocks access to domains with an address of You can create an extensive hosts file to exert control over how your computer access hosts over the network.
This is often required in corporate settings where internal networks are employed. You can also leave the hosts file alone and let DNS handle locating and forwarding your network traffic. Since the absence of an entry for a designated domain in your hosts file does not preclude you reaching that site through a DNS lookup, you might be wondering why you would ever want to edit it. There are several reasons why editing your hosts file makes sense to improve your speed when connecting over the network. You may also encounter situations where the hosts file is not working as it was intended to and is causing connection failures or other issues with your network traffic.
Today, many users never access their hosts file and get along quite well using DNS servers to lookup IP addresses. While you may never need to edit your hosts file , having the ability to do so gives you control over how your computer interacts with the Internet. Jeff Cochin is a data management and recovery expert. He also serves as a technical writer, testing and reviewing tech solutions in various fields.