Summarize:

The hosts file allows you to block websites from being accessed on the computer you are using. It works for all accounts on the computer. Editing a host file will block a website, but does not offer any additional features such as tracking or time limits. Tech-savvy users may be able to change the host file and circumvent blocks.  Navigate to C:\Windows\System32\drivers\etc and double-click it. Use Notepad to open the file when prompted to choose a program.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/d\/d5\/Block-a-Website-in-All-Web-Browsers-Step-2-Version-2.jpg\/v4-460px-Block-a-Website-in-All-Web-Browsers-Step-2-Version-2.jpg","bigUrl":"\/images\/thumb\/d\/d5\/Block-a-Website-in-All-Web-Browsers-Step-2-Version-2.jpg\/aid792339-v4-728px-Block-a-Website-in-All-Web-Browsers-Step-2-Version-2.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Place your cursor at the bottom of the document. Put a blank line between your starting point and the end of the existing text.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/b\/b0\/Block-a-Website-in-All-Web-Browsers-Step-4.jpg\/v4-460px-Block-a-Website-in-All-Web-Browsers-Step-4.jpg","bigUrl":"\/images\/thumb\/b\/b0\/Block-a-Website-in-All-Web-Browsers-Step-4.jpg\/aid792339-v4-728px-Block-a-Website-in-All-Web-Browsers-Step-4.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Enter 127.0.0.1 <website> and press Enter. Replace <website> with the website that you want to block (facebook.com, youtube.com, etc.).    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/c\/cb\/Block-a-Website-in-All-Web-Browsers-Step-5Bullet1-Version-2.jpg\/v4-460px-Block-a-Website-in-All-Web-Browsers-Step-5Bullet1-Version-2.jpg","bigUrl":"\/images\/thumb\/c\/cb\/Block-a-Website-in-All-Web-Browsers-Step-5Bullet1-Version-2.jpg\/aid792339-v4-728px-Block-a-Website-in-All-Web-Browsers-Step-5Bullet1-Version-2.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Enter another line with the same information except add the “www.” before the website. In essence you should have two entries per website that you want to block: 127.0.0.1 facebook.com AND 127.0.0.1 www.facebook.com.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/2\/22\/Block-Websites-Step-19Bullet4.jpg\/v4-460px-Block-Websites-Step-19Bullet4.jpg","bigUrl":"\/images\/thumb\/2\/22\/Block-Websites-Step-19Bullet4.jpg\/aid792339-v4-728px-Block-Websites-Step-19Bullet4.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Repeat this for each website that you want to block.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/e\/e6\/Block-a-Website-in-All-Web-Browsers-Step-5Bullet2.jpg\/v4-460px-Block-a-Website-in-All-Web-Browsers-Step-5Bullet2.jpg","bigUrl":"\/images\/thumb\/e\/e6\/Block-a-Website-in-All-Web-Browsers-Step-5Bullet2.jpg\/aid792339-v4-728px-Block-a-Website-in-All-Web-Browsers-Step-5Bullet2.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Save the file. Do not change the name, file type, or location of the file. Simply save the changes you’ve made. You may have to restart your browser for the changes to take effect. In case you are not able to edit host file you can also run notepad as administrator by right clicking on it and then open host file from the suitable location mentioned above. The hosts file allows you to block websites from being accessed on the computer you are using. It works for all accounts on the computer. Launch the Terminal, which can be found in the Utilities folder.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/f\/fc\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-2.jpg\/v4-460px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-2.jpg","bigUrl":"\/images\/thumb\/f\/fc\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-2.jpg\/aid792339-v4-728px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-2.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Create a backup of the hosts file. You can create a backup of the hosts file by entering the following command and pressing Enter: sudo /bin/cp /etc/hosts /etc/hosts-original. You may have to enter your administrator password.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/f\/f5\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-3.jpg\/v4-460px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-3.jpg","bigUrl":"\/images\/thumb\/f\/f5\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-3.jpg\/aid792339-v4-728px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-3.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Edit the hosts file. To edit the hosts file, you need to open it in nano with the following command: sudo nano /etc/hosts/. This will open the nano window and you will see the hosts file text.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/3\/33\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-6.jpg\/v4-460px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-6.jpg","bigUrl":"\/images\/thumb\/3\/33\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-6.jpg\/aid792339-v4-728px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-6.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Start a new line at the bottom of the file. Enter 127.0.0.1 <website> and press Enter. Replace <website> with the website that you want to block (facebook.com, youtube.com, etc.).    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/d\/d9\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-7.jpg\/v4-460px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-7.jpg","bigUrl":"\/images\/thumb\/d\/d9\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-7.jpg\/aid792339-v4-728px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-7.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Enter another line with the same information except add the “www.” before the website. In essence you should have two entries per website that you want to block: 127.0.0.1 facebook.com AND 127.0.0.1 www.facebook.com.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/3\/39\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-9.jpg\/v4-460px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-9.jpg","bigUrl":"\/images\/thumb\/3\/39\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-9.jpg\/aid792339-v4-728px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-9.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Repeat this for each website that you want to block.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/1\/1e\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-10.jpg\/v4-460px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-10.jpg","bigUrl":"\/images\/thumb\/1\/1e\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-10.jpg\/aid792339-v4-728px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-10.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Save your changes by pressing Ctrl + O. Once the changes are saved, press Ctrl + X to exit nano.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/1\/10\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-11.jpg\/v4-460px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-11.jpg","bigUrl":"\/images\/thumb\/1\/10\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-11.jpg\/aid792339-v4-728px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-11.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"}  Flush your DNS. Use the DNS flush command sudo dscacheutil –flush cache to reset your DNS and load the new settings. Your browser should now block the sites you listed in the hosts file.    {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/d\/d5\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-12.jpg\/v4-460px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-12.jpg","bigUrl":"\/images\/thumb\/d\/d5\/Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-12.jpg\/aid792339-v4-728px-Block-and-Unblock-Internet-Sites-%28On-a-Mac%29-Step-12.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"<div class=\"mw-parser-output\"><p>License: <a rel=\"nofollow\" class=\"external text\" href=\"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\">Creative Commons<\/a><br>\n<\/p><p><br \/>\n<\/p><\/div>"} The drawback of the hosts file method is that the hosts file needs to be changed on every computer that you want to protect. If your network has a lot of computers on it, this may prove unfeasible.
Edit the hosts file in Windows. Edit the hosts file on a Mac. Repeat these steps on each computer you want to protect.