• How to open mac hosts file. How to Edit the Hosts File on Mac. How to edit the Hosts file

    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 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 - .

    So why would you want to change your hosts file?

    if you enter a web address in your browser, it’s because you want to typically reach that IP address. So what are the benefits of rerouting?

      Network Testing: If you’re developing a network, you can reroute the real domain name to the development site to see how real users experience it. This will not affect other users accessing the real site.

      Block Malicious Sites: Apart from the risk of viruses and malware, undetected add-ons can also find their way into your system and begin slowing things down. Although it’s always worth investing in pop-up ad blockers, editing the hosts file prevents known malicious sites from being accessed. If a link or pop-up attempts to enter the site, your OS simply re-routes it and takes you to a safer page.

      Increased Speed: As we said earlier, finding a website via the DNS is like flicking through the yellow pages for the correct address. With the hosts file being localized to your Mac, this could potentially speed up your browsing by omitting the middle man.

      Improved Productivity: Maybe you or your team are getting distracted with social media sites or video streaming. Blocking access to time-wasting sites is a good way of keeping focused on the job at hand.

    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/hosts and 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 mDNSResponder and 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.

    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.

    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 can you 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 , 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:

    1. Launch CleanMyMac X ()
    2. Select System Junk.
    3. Click Scan > Clean.

    In case you need to remove just DNS cache, do the following:

    1. Go to the Maintenance module.
    2. Choose Flush DNS Cache.
    3. Click Run.

    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.

    By editing Mac hosts file, it’s possible to emulate DNS change and set the desired IP for a domain name. With the hosts file you can overwrite any DNS values ​​set by your Internet service provider. This is helpful if your domain name is not yet registered or not pointed to a hosting account, but you want to preview your website.

    In this tutorial you will learn how to edit the hosts file on Mac. For a tutorial on how to do the same on Windows.

    IMPORTANT: Note that changes made for the hosts file will affect your computer only.

    What do you'll need

    Before you begin this guide, you'll need the following:

    • root user privileges

    Step 1 – Opening Hosts File

    Follow these steps to open your hosts file on Mac:

    Step 2 – Editing Hosts File on Mac

    In order to emulate DNS change and point domain name to an IP address, use the following syntax:

    IP_Address domain.com IP_Address www.domain.com

    For example, to emulate DNS change for website and www.site we would have to include the following lines at the bottom of hosts file.

    93.188.160..188.160.58 www.site

    This will emulate change IP address of the website and www.site to 93.188.160.58.

    Once you are done with editing hosts file, press CMD+X on your keyboard, enter Y to save changes and hit ENTER button.

    Step 3 – Flushing DNS Cache (Optional)

    Sometimes changes do not apply instantly and you may need to flush the DNS cache. On Mac, DNS cache can be easily flushed by executing the following command:

    Mac OS X Snow Leopard

    Sudo dscacheutil -flushcache

    OS X Mavericks, Mountain Lion, and Lion

    Sudo discoveryutil mdnsflushcache

    Conclusion

    That’s it, by finishing this short tutorial, you have learned how to edit a hosts file on Mac. This is useful if your domain name is not registered or not pointed to the server, but you want to preview your website. In addition, you have also learned how to flush the DNS cache on Mac.

    Active computer users are probably familiar with the Hosts file, which contains network information. Through it, you can block access to a specific site from your computer, or make other changes to how your computer accesses a specific IP address. Despite how closed the Mac OS operating system is from user interference, you can edit the Hosts file in it. At the same time, editing is no more difficult than on Windows, and in this article we will look at how to do this.

    Table of contents:

    How to open and edit Hosts via “Terminal”

    The easiest way to access editing a file is to use the command line, which on Mac OS is called . You can launch the “Terminal” utility through the Finder, it is located in the list of standard programs of the operating system, or through a search by entering its name.

    Having launched “Terminal”, enter the following command and execute it to proceed to editing the Hosts file:

    Sudo nano /private/etc/hosts

    After activating the command, you will also need to enter the computer administrator password, since interference with Hosts is quite serious, and if you edit the file incorrectly, problems with accessing some sites on the Internet may occur.

    After entering the password, the contents of the Hosts file will appear directly, which the user can edit. The mouse does not work when editing a file through the “Terminal”, that is, you can only move between lines of the file with the keyboard. Enter the changes you would like to make to the Hosts file. To save changes to the file, you need to press Ctrl+X on your keyboard. Next, a message will appear asking if you really want to change Hosts, confirm the action with the “Y” button.

    How to Open and Edit Hosts in Mac OS via Finder

    The second option to access Hosts and edit the file is to use the standard Finder. Using this method, you can open the Hosts file and edit it in any text editor, so this option may be preferable in some cases.

    To open Hosts through the Finder, right-click on the Finder in the bottom menu and select the “Go to Folder” option.

    A window will open in which you need to enter the path to the folder you want to go to. Enter the following address:

    /private/etc/hosts

    And click “Go”.

    The system folder will open in which the Hosts file is located. To start editing it, you need to right-click on it and select the editor in which it is more convenient for you to work (you can also use the standard editor - TextEdit).

    In the window that opens, you can edit the Hosts file like any other file in a text editor. However, the system Hosts file is protected from editing. After you try to make changes to it, messages will appear asking you to create a duplicate file. Click “Duplicate”, after which a second one is created based on the first file.

    Next, all that remains is to make the necessary changes to the newly created file and save it in a convenient place, for example, on your desktop. When saving, select the .txt resolution (the same resolution as the original Hosts file). When you save the new file, you just need to replace the old file in the system folder etc. To do this, drag the new file into the folder where the old Hosts is located and click “Replace” when the corresponding message appears. As a result of these actions, the old Hosts file will be deleted, and the system will begin to use the new one instead.

    How to apply changes to the Hosts file

    Some changes that are made to the Hosts file are not immediately perceived by the system and, accordingly, have no effect. For the changes to take effect, you need to update the DNS cache. This can be done using the terminal using the command:

    Dscacheutil -flushcache; sudo killall -HUP mDNSResponder

    After executing this command, the Hosts file will be read by the system again, and all changes that have been made to it will be reflected in the operation of the computer.

    Fair, not overpriced and not underestimated. There should be prices on the Service website. Necessarily! without asterisks, clear and detailed, where technically possible - as accurate and concise as possible.

    If spare parts are available, up to 85% of complex repairs can be completed in 1-2 days. Modular repairs require much less time. The website shows the approximate duration of any repair.

    Warranty and responsibility

    A guarantee must be given for any repairs. Everything is described on the website and in the documents. The guarantee is self-confidence and respect for you. A 3-6 month warranty is good and sufficient. It is needed to check quality and hidden defects that cannot be detected immediately. You see honest and realistic terms (not 3 years), you can be sure that they will help you.

    Half the success in Apple repair is the quality and reliability of spare parts, so a good service works directly with suppliers, there are always several reliable channels and your own warehouse with proven spare parts for current models, so you don’t have to waste extra time.

    Free diagnostics

    This is very important and has already become a rule of good manners for the service center. Diagnostics is the most difficult and important part of the repair, but you don't have to pay a penny for it, even if you don't repair the device based on its results.

    Service repairs and delivery

    A good service values ​​your time, so it offers free delivery. And for the same reason, repairs are carried out only in the workshop of a service center: they can be done correctly and according to technology only in a prepared place.

    Convenient schedule

    If the Service works for you, and not for itself, then it is always open! absolutely. The schedule should be convenient to fit in before and after work. Good service works on weekends and holidays. We are waiting for you and working on your devices every day: 9:00 - 21:00

    The reputation of professionals consists of several points

    Company age and experience

    Reliable and experienced service has been known for a long time.
    If a company has been on the market for many years and has managed to establish itself as an expert, people turn to it, write about it, and recommend it. We know what we are talking about, since 98% of incoming devices in the service center are restored.
    Other service centers trust us and refer complex cases to us.

    How many masters in areas

    If there are always several engineers waiting for you for each type of equipment, you can be sure:
    1. there will be no queue (or it will be minimal) - your device will be taken care of right away.
    2. you give your Macbook for repair to an expert in the field of Mac repairs. He knows all the secrets of these devices

    Technical literacy

    If you ask a question, a specialist should answer it as accurately as possible.
    So that you can imagine what exactly you need.
    They will try to solve the problem. In most cases, from the description you can understand what happened and how to fix the problem.

    One of the most common questions regarding Windows is where is hosts located?. In this article I will talk about the location of this file in any OS, why it is needed at all, and why it is edited. Usually they are looking for it in order to fix a problem with access to the site or, on the contrary, to block access to it. In any case, in this article I will tell you not only where the hosts file is located in Windows 10, but I will also look at other operating systems, even Linux,

    Hosts in Windows 10

    Typically the hosts file in Windows is located in the folder

    %windir%/system32/drivers/etc/

    The path to it can be inserted into the explorer.


    Or open the file directly using the run command (Win + R):

    %windir%/system32/drivers/etc/hosts
    Path to hosts file

    It is no coincidence that the %windir% variable is indicated in the path - it contains the path to the Windows folder, regardless of where it is located. For example, the folder might be called . Regardless of the system bit size, the hosts file is always located in the same place in Windows 10. The only problem you may encounter is that the file is not allowed to edit. In this case, I recommend reading the article.

    Where is the file located in hosts windows 7

    The path to the hosts file in Windows 7 is no different from the path in other versions of Windows. However, just in case, I will provide here screenshots of how to find the hosts file in Windows 7 64 and 32 bits.


    Hosts file in Windows 7

    Enter the path to the hosts file %windir%/system32/drivers/etc/hosts and use the Notepad program, or better yet, install Notepad++. In it you will not have any problems with rights.


    And finally, I’ll tell you where the file is located in other operating systems other than the Windows family.

    Hosts on Mac OS

    You may need to edit the hosts file in MacOS X. To do this, open the Terminal program and enter the command in it:

    Sudo nano /private/etc/hosts

    Enter your password and press Enter. Navigate through the file using the arrows, make the necessary changes and press Ctrl + O to save the file. Answer yes to the question about saving. Or press Ctrl + X to exit to the terminal and answer yes to the question about saving the file. After this procedure it is advisable.

    By the way, on Linux the hosts file is usually located at /etc/hosts. You can edit it in the same way as MacOS - through the nano editor.

    In all Windows systems, the hosts file is always located in the same folder, this has already been mentioned above. You can remember this simple way; most likely, you will have to use it more than once or twice. Personally, I very often have to edit the hosts file and it’s quite convenient to do this without resorting to instructions. If you have comments regarding this article, please share them in the form below. Good luck!