{"id":476839,"date":"2022-07-23T00:00:00","date_gmt":"2022-07-22T21:00:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-edit-your-hosts-file-on-windows-mac-or-linux\/"},"modified":"2022-07-23T00:00:00","modified_gmt":"2022-07-22T21:00:00","slug":"how-to-edit-your-hosts-file-on-windows-mac-or-linux","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-edit-your-hosts-file-on-windows-mac-or-linux\/","title":{"rendered":"#How to Edit Your Hosts File on Windows, Mac, or Linux"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2d22abe3db8\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2d22abe3db8\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-edit-your-hosts-file-on-windows-mac-or-linux\/#%E2%80%9CHow_to_Edit_Your_Hosts_File_on_Windows_Mac_or_Linux%E2%80%9D\" >&#8220;How to Edit Your Hosts File on Windows, Mac, or Linux&#8221;<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-edit-your-hosts-file-on-windows-mac-or-linux\/#Editing_the_Hosts_File_on_Windows_10_or_11\" >Editing the Hosts File on Windows 10 or 11<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-edit-your-hosts-file-on-windows-mac-or-linux\/#Editing_the_Hosts_File_on_Windows_8_or_81\" >Editing the Hosts File on Windows 8 or 8.1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-edit-your-hosts-file-on-windows-mac-or-linux\/#Windows_7\" >Windows 7<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-edit-your-hosts-file-on-windows-mac-or-linux\/#Edit_The_Hosts_File_On_Ubuntu\" >Edit The Hosts File On Ubuntu<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-edit-your-hosts-file-on-windows-mac-or-linux\/#Change_the_Hosts_File_on_Any_macOS_Version\" >Change the Hosts File on Any macOS Version<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-edit-your-hosts-file-on-windows-mac-or-linux\/#Why_Isnt_The_Hosts_File_Blocking_Connections\" >Why Isn\u2019t The Hosts File Blocking Connections?<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E2%80%9CHow_to_Edit_Your_Hosts_File_on_Windows_Mac_or_Linux%E2%80%9D\"><\/span>&#8220;How to Edit Your Hosts File on Windows, Mac, or Linux&#8221;<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<div>\n<figure style=\"width: 1200px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage size-full wp-image-743777\" data-pagespeed-no-defer=\"\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/07\/shutterstock_606660923.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1200\" height=\"675\"\/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-vector\/abstract-world-network-internet-global-connection-606660923\">TAW4\/Shutterstock.com<\/a><\/span><\/figcaption><\/figure>\n<p>Occasionally you may need to edit the hosts file on your machine. Your host file might have been edited maliciously in an attack, or as a prank. Alternatively, you may just want to control access to certain websites or control network traffic.<\/p>\n<p>Computers have had hosts files since the ARPANET days. The hosts files were used to resolve host names for decades before the DNS system was implemented. Since they were used to aide in network name resolution, hosts files grew to become massive documents.<\/p>\n<p>Microsoft, <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">App<\/a>le, and other operating system developers have kept the hosts file around, which is why it varies very little between Windows, macOS, and Linux. The syntax stays mostly the same across all platforms. Most hosts files will have several entries for loopback. We can use that for the basic example for the typical syntax.<\/p>\n<p>The first part will be the location to redirect the address to, the second part will be the address that you will want to redirect, and the third part is the comment. They can be separated by a space, but for ease of reading are typically separated by one or two tabs, or the equivalent amount of spaces.<\/p>\n<pre>127.0.0.1 localhosts #loopback<\/pre>\n<p>Now let\u2019s look at accessing the hosts files in different operating systems.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Editing_the_Hosts_File_on_Windows_10_or_11\"><\/span>Editing the Hosts File on Windows 10 or 11<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The hosts file is still present in the latest and greatest from Microsoft \u2014 <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/784196\/how-to-edit-the-hosts-file-on-windows-10-or-11\/\">Windows 10 and Windows 11 \u2014 despite being ancient by computer standards. It isn\u2019t used much in in modern Windows networking, however.<\/p>\n<p>The hosts file, like other files that can be found in the Windows folder, is protected. You need administrative privileges to move, edit, or delete the file.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>How to Edit the hosts File on Windows 10 or 11<\/em><\/strong><\/p>\n<p>You can use any plain text editor you want to modify the hosts file, however Notepad is perfectly adequate for the task. You don\u2019t need to go download another one just for this job.<\/p>\n<p>Hit the Start button, type \u201cnotepad\u201d into the search, and then right-click it and hit \u201cRun as Administrator.\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-818247\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2017\/04\/launch-notepad-as-administrator-windows-11.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"500\" height=\"370\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Click on \u201cFile\u201d in the top left corner, hit \u201cOpen,\u201d and then navigate to:<\/p>\n<pre>C:\\Windows\\System32\\drivers\\etc<\/pre>\n<p>Make sure to change the select to \u201cAll Files (*.*)\u201d rather than \u201cText Documents (*.txt).\u201d The hosts file doesn\u2019t have a file extension, so it won\u2019t show up if you\u2019re only displaying text documents. After you change that setting, locate the \u201chosts\u201d fileand click open.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-818248\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2017\/04\/open-the-hosts-file-with-notepad.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Open the hosts file with Notepad. Make sure to change it to &quot;All Files.&quot;\" width=\"650\" height=\"436\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You can then edit the hosts file however you\u2019d like. There are a few obvious things to do with it, like block or reroute internet traffic.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>How to Use Your Computer&#8217;s Hosts File to Block Tons of Malware, Porn, and Other Types of Websites<\/em><\/strong><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Editing_the_Hosts_File_on_Windows_8_or_81\"><\/span>Editing the Hosts File on Windows 8 or 8.1<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Editing the hosts file on Windows 8 and 8.1 is basically the same as Windows 10 or 11.<\/p>\n<p>Just search for Notepad, right-click on Notepad in the search results list, and then choose\u00a0 \u201cRun as Administrator.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-180704\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2014\/01\/img_52e68b62d824b.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Once you\u2019ve opened Notepad, click \u201cFile\u201d in the top right, click \u201cOpen,\u201d and then navigate to the \/etc\/ folder:<\/p>\n<pre>C:\\Windows\\System32\\drivers\\etc\\hosts<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-222982\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2015\/02\/Windows_104-650x349.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"650\" height=\"349\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You\u2019ll be able to edit the hosts file like you would any other file. You can use it to<a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/122404\/how-to-block-websites-in-windows-8s-hosts-file\/\"> block access to websites, if you want.<\/p>\n<blockquote class=\"admonishment_tip\"><p><strong>Tip:<\/strong> If you get an error notifying you that you don\u2019t have permission, you didn\u2019t actually run Notepad as administrator.<\/p><\/blockquote>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Windows_7\"><\/span><a rel=\"nofollow noopener\" target=\"_blank\" name=\"autotoc_anchor_2\">Windows 7<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Accessing the hosts file in Windows 7 is the same as on newer versions of Windows. You need to run Notepad as administrator, navigate to the hosts file, and then open it up.<\/p>\n<p>There are a few ways you can do this. The first is to find Notepad, right-click it, hit \u201cRun as Administrator,\u201d and then navigate to the hosts file. It is located at:<\/p>\n<pre>C:\\Windows\\system32\\drivers\\etc\\<\/pre>\n<p>Alternatively, you can hit Windows+R to open up a Run window, and then enter the following command:<\/p>\n<pre>notepad c:\\windows\\system32\\drivers\\etc\\hosts<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2010\/08\/sshot20100831194119.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"455\" height=\"263\" border=\"0\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The command will run Notepad as administrator and automatically open the specified file.<\/p>\n<p>Once notepad is open you can edit the file. In this example we will block Facebook. To do this just enter in the following after the # mark.<\/p>\n<pre>0.0.0.0\u00a0\u00a0\u00a0 <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.facebook.com\">www.facebook.com<\/a>&#13;\n<\/pre>\n<blockquote class=\"admonishment_note\"><p><strong>Note:<\/strong> You can also use the loopback address instead of 0.0.0.0, but that is basically up to personal preference.<\/p><\/blockquote>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2010\/08\/sshot20100831205149.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"637\" height=\"414\" border=\"0\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Now that you have edited your Hosts file make sure to save it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2010\/08\/sshot20100831205407.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"637\" height=\"414\" border=\"0\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Now notice if we try to access Facebook in IE we can\u2019t get to the page.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2010\/08\/sshot20100831205644.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"588\" height=\"380\" border=\"0\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We also were not able to get to it in Google Chrome\u2026 (check notes at the end). Also for more info on editing your Hosts file, check out The Geek\u2019s article on how to create a shortcut to quickly edit your Hosts file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2010\/08\/sshot20100831210427.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"512\" height=\"412\" border=\"0\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Edit_The_Hosts_File_On_Ubuntu\"><\/span>Edit The Hosts File On Ubuntu<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In Ubuntu (and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/132624\/htg-explains-whats-a-linux-distro-and-how-are-they-different\/\">most Linux distributions) you can edit the hosts file directly in the Terminal. You can use your favorite command-line editor or your favorite GUI text editor. For this example we will use Vim, since it is one of the traditional text editors in Linux. Like Windows, Ubuntu\u2019s hosts file is located in the <em>\/etc\/<\/em> folder, though here it is in the root of the drive. The hosts file is protected, and your regular user account will not be able to edit it.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>Define a Great Vim Profile Using .vimrc<\/em><\/strong><\/p>\n<p>You\u2019ll need to launch Vim prefaced by sudo, which is conceptually and functionally similar to \u201cRun as Administrator\u201d on Windows operating systems. Open up a Terminal, then enter:<\/p>\n<pre>sudo vim \\etc\\hosts<\/pre>\n<p>You\u2019ll need to enter your password before the command will execute.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>How to Control sudo Access on Linux<\/em><\/strong><\/p>\n<blockquote class=\"admonishment_note\"><p><strong>Note:<\/strong> If you get a message notifying you that Vim is not installed, just run \u201csudo apt install vim\u201d in a Terminal.<\/p><\/blockquote>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-818264\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2017\/04\/ubuntu.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Run &quot;sudo vim \\etc\\hosts&quot; in a Terminal. \" width=\"550\" height=\"415\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>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 IPv6.<\/p>\n<p>You can ignore the IPv6 section in most cases; just editing the IPv4 section should do what you need.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-818265\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2017\/04\/block-facebook.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"An entry in the hosts file that will block Facebook. \" width=\"734\" height=\"552\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Now we can save the file and try to go to Facebook.com. When you set the address in the hosts file to 0.0.0.0, your computer can\u2019t reach Facebook, and throws an error: \u201cUnable to Connect.\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-818268\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2017\/04\/unable-to-ocnnect.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The browser cannot connect to Facebook.com.\" width=\"641\" height=\"500\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<blockquote class=\"admonishment_note\"><p><strong>Note:<\/strong> If your browser has been configured to use DNS Over HTTPS and its own DNS Server, editing the hosts file will probably not block access.<\/p><\/blockquote>\n<p><strong>RELATED:<\/strong> <strong><em>How to Set DNS Search Order in Ubuntu 18.04 using NetPlan<\/em><\/strong><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Change_the_Hosts_File_on_Any_macOS_Version\"><\/span>Change the Hosts File on Any macOS Version<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In macOS, accessing the hosts file is very similar to Ubuntu. Begin in terminal and use your favorite editor \u2014 it could even be a GUI-based text editor if you wish, but it is easier to use a command-line editor from the Terminal.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-818670\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2017\/04\/use-sudo-to-runvim-macos.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Running Vim as Sudo is the only way to access the hosts file. You'll be prompted for a password.\" width=\"504\" height=\"368\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The file will look a lot like the hosts file found in Windows and Linux. Again we are going to redirect Facebook to 0.0.0.0.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-818671\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2017\/04\/macOS-hosts-file.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The MacOS hosts file.\" width=\"505\" height=\"372\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Safari, just like a browser on Windows and Ubuntu, will be unable to connect to Facebook.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-818672\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2017\/04\/safari-cannot-connect-to-acebook.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Safari's connection to Facebook was blocked.\" width=\"776\" height=\"487\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Why_Isnt_The_Hosts_File_Blocking_Connections\"><\/span><a rel=\"nofollow noopener\" target=\"_blank\" name=\"autotoc_anchor_5\">Why Isn\u2019t The Hosts File Blocking Connections?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>All of the major modern browsers offer <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/448629\/how-dns-over-https-doh-will-boost-privacy-online\/\">DNS Over HTTPS (DOH). DOH encrypts your DNS requests so that they can\u2019t be intercepted and read by third parties that might be snooping \u2014 in general, this is a great thing.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>How DNS Over HTTPS (DoH) Will Boost Privacy Online<\/em><\/strong><\/p>\n<p>For our purposes here, it limits the utility of the hosts file. The hosts file can <strong><em>only <\/em><\/strong>be used to block internet traffic if your browser is deferring to the DNS Server specified in the Windows operating system. A lot of browsers will enable DNS Over HTTPS automatically and use their own DNS servers. That results in the browser completely bypassing the hosts file. It is possible to force your browser to use the DNS Server Windows specifies, but you\u2019ll have to dig through your browser\u2019s settings.<\/p>\n<p>This should get you started in understanding the Hosts file and how it can help protect your computer. Under the right circumstances, you can use it to block sites that you don\u2019t want a PC to be able to access.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>Stupid Geek Tricks: Create a Shortcut to Quickly Edit Your Hosts File<\/em><\/strong><\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/howto\/27350\/beginner-geek-how-to-edit-your-hosts-file\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;How to Edit Your Hosts File on Windows, Mac, or Linux&#8221; TAW4\/Shutterstock.com Occasionally you may need to edit the hosts file on your machine. Your host file might have been edited maliciously in an attack, or as a prank. Alternatively, you may just want to control access to certain websites or control network traffic. Computers&#8230;<\/p>\n","protected":false},"author":1,"featured_media":476840,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/07\/shutterstock_606660923.png?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-476839","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/476839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=476839"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/476839\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/476840"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=476839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=476839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=476839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}