Are you spending too much time on social media websites such as Instagram, Twitter, Facebook, etc.? Or is your younger brother, sister, son or anyone wasting too much time on a particular website or visiting the website he/she is not supposed to visit? What if we tell you in this article that you can block any website with just 1 line of code. You don’t even have to be a coder to do this task and that too with ease. So let us get started.
- Go to File Explorer, Search Panel, or press the Window Key.
- In the search panel, search for Notepad.
- When the search results will come up, right click on the Notepad and click on Run as administrator option.
- After that using the Notepad, open the file in the following path C:\Windows\System32\Drivers\etc\hosts
127.0.0.1 www.instagram.com instagram.com
- Next Save your file.
For Mac & Linux:
- Open the Terminal Window.
- Open the hosts file in the text editor, by entering the following command: sudo nano /etc/hosts
- Enter the password of that user next.
- Add 127.0.0.1 www.instagram.com instagram.com
- Press the X-Control button.
- Save your file then. If you are prompted and asked if you want to save your changes, then press Y.
This is going to work most of the time, and then you won’t be able to open the website mentioned in the host’s file. The below result will come up after going through all the steps.
Just in case the above method does not work, then you are going to have to clear the cache of the browser.
For Google Chrome:
- Open Google Chrome.
- Go to Settings afterwards.
- Click on More Tools and then click on Clear Browsing Data.
- After that Check, all the boxes of “Cached images and files” and “Cookies and other site data” to clear them.
- Then click on Clear Data button.
For Mozilla Firefox:
- Open Mozilla Firefox.
- Click on Menu button and go to Preferences.
- Go to the Privacy & Security panel.
- After that go to the Cookies and Site Data section.
- Then checkmark the boxes of “Cached Web Content”, and click on “Clear Data” afterward.
Every website on our internet is not found by its name of the domain. Instead, it is found by it’s IP address. The host’s file contains the list of IP addresses and all the hostnames associated along with it, in an address book. When any website like www.instagram.com is entered by the client in the browser, the consultation happens from the host’s file, and we get the IP address for that particular site. After that, the compiler is going to open the website after calling it. If that doesn’t happen, the computer will be going to ask for the Internet Service Provider AKA ISP for the IP Address, before requesting that particular site. For most of the times, the host’s file will not be having any addresses, just because we haven’t put anything there. So the computer will inquire for the IP address from the required ISP, which will in return going to consult a DNS server, which will further be going to find the IP address. Once the browser is going to receive the accurate IP address, the connection is going to be built with the server that is going to match the IP address which will further transfer and receive data & information. This is how the page of the website will load up.
For the given example above, the website www.instagram.com is pointed to 127.0.0.1, which is localhost. Localhost a synonym for the home computer, which is a method of portraying to the machine, that the user is currently logged into and since the server is not running locally, it will lead us to “the site cannot be reached.” The web server could be set up on the computer and 127.0.0.1 could be used to point it to the server in the local machine, and the local server will return something similar to this.