There are a lot of unsafe and malicious websites out there. Due to online spam, illegal content, social media addiction and other bad things happening over Internet, it become necessary to block some sites on your children's phone. After all, it is solely your responsibility to keep them away from such things.
As like in Windows, there is a hosts file in Android system which allows you to re-direct domain names to an IP address of your choice. If you would like to block certain websites on your phone, you can simply add them in this hosts file. This is one of the best, effective and evergreen method. Here's a complete guide on this topic.
A hosts file is a simple plain-text file which is used for mapping hostnames to IP addresses. When you try to visit a website, browser will first search the hosts file to find the mapped IP address of that hostname.
If it's found there, then the web page will be accessed from that IP address, otherwise a query is sent to the DNS server (Domain Name System) to find the real IP address of hostname.
So basically, hosts file is used to re-direct domain name to an IP address of your choice. With this approach, we can block any website by re-directing it back to the system or Localhost. (I will explain it later)
This method will work only in rooted Android phones. First you need to install ES File Explorer app. As hosts file is located in the root directory of Android system, so it can't be accessed from normal file managers. Once after installing it, follow this step-by-step guide -
As like in Windows, there is a hosts file in Android system which allows you to re-direct domain names to an IP address of your choice. If you would like to block certain websites on your phone, you can simply add them in this hosts file. This is one of the best, effective and evergreen method. Here's a complete guide on this topic.
What is a hosts file in Android?
A hosts file is a simple plain-text file which is used for mapping hostnames to IP addresses. When you try to visit a website, browser will first search the hosts file to find the mapped IP address of that hostname.
If it's found there, then the web page will be accessed from that IP address, otherwise a query is sent to the DNS server (Domain Name System) to find the real IP address of hostname.
So basically, hosts file is used to re-direct domain name to an IP address of your choice. With this approach, we can block any website by re-directing it back to the system or Localhost. (I will explain it later)
Benefits of blocking sites through hosts file
- Best thing is, it will block website across all browsers and apps in your Android phone. (One arrow, multiple targets)
- You can also block ad servers and trackers to improve user experience and website loading time.
- You can play a prank on your friends by blocking or redirecting some popular websites on their phone like Google and Facebook.
Block websites in Android with hosts file
This method will work only in rooted Android phones. First you need to install ES File Explorer app. As hosts file is located in the root directory of Android system, so it can't be accessed from normal file managers. Once after installing it, follow this step-by-step guide -
- Launch the ES File Explorer app and go to /system/etc/ folder.
- Here find the hosts file and open it as Text.
- Then select the ES Note Editor app.
- Now click the menu button (three dots at the top-right corner) and then tap Edit option.
- To block a website, simply add this line: 127.0.0.1 example.com
For example, if you want block Google, add this: 127.0.0.1 google.com
Here 127.0.0.1 (or localhost) is the standard hostname given to the address of your device. When you write 127.0.0.1 google.com, it means google.com will be redirected to 127.0.0.1 IP address which is your localhost by default, hence website can't be accessed. - Finally save the changes.
It doesn't work
ReplyDeleteit says error
ReplyDeleteThe phone needs to be rooted first. It won't work otherwise.
DeleteYou can't edit the hosts file on Android.
ReplyDeleteYou forgot to mention that this method only works if the mobile is rooted.
ReplyDeleteRooted but still failed, because the file system is read-only
ReplyDeleteHad the same problem as Jim, file can't be saved because it's read-only.
ReplyDelete