As we all know we can block any websites from our computer using Windows host files. If we are using wireless routers, then also we can block websites using routers, so we can prevent our children from accessing porn sites from their devices. But this is limited to wifi connection only, what if they activate a data plan on their mobile and start using such sites?
Well, you can edit & modify the Android host files to block specific websites. You can monitor your child’s activity on Android, to check which sites they browse most often. If you think the sites they are browsing are unsafe for your children, you can block that site using your computer by using the following tutorial.
Related: Block Ads on Android
Please note that the process requires a rooted phone. So you must root your device before you start the procedure. If you don’t know how to root your Android device, just comment on your Android device’s model number, name, and specification if any. We will write a tutorial on how to root your device here.
How to Modify Hosts File on Android:
This is the easiest way to edit the host’s file on your Android device, you can use Android Debug Bridge(ADB). So set up & install the Android Debug Bridge Utility. Once you have done this, navigate into the folder where ADB is located and type cmd into the location bar, which will open a command prompt in the current folder.
Once the command prompt window opens, type “adb devices” without quotes to see what device is attached to your computer.
Now you will need to get the location of the Android Hosts file and download it so that you can modify it and add the sites that you want to get blocked on your Android smartphone. Type the following command on the command prompt.
adb pull /system/etc/hosts F:\hosts
What the command does is, it will copy the android hosts file from system>etc>hosts and will copy it on your computer’s F drive.
Right-click on the host file copied in your F drive and open it with a notepad. Once it is opened, you will see the notepad file as shown in the image with some entries. Here you will add as many sites as you want.
Suppose you want to block the yahoo.com site, you will need to add 127.0.0.1 yahoo.com at the bottom. if you want to block thepiratebay, add another entry 127.0.0.1 thepiratebay. sx this way when the user types thepiratebay. sx in the Android device, it will be redirected to the local host and will not let the user browse that added site in that list.
Related: How to Rename Files in Bulk using ES File Explorer File Manager
You have modified the host file from your local drive on the computer. Now you will have to overwrite the host file on your Android system>etc>hosts. So open the command prompt and type the following command to replace the old host file with a modified host file.
adb push F:\hosts /system/etc/
So it will transfer the file from the F drive of your computer and replace the old host’s file with the modified one.
See, we have blocked Facebook.com from the host’s file, so whenever a user types facebook.com from the browser, it will not open.
You can also use the Hosts Editor Android app, which is available free on the Google Play Store if you don’t want to edit it through your computer. You can easily modify your Android’s host file using that host’s editor Android app.
Related: Best Website Blocker App – Use Without Rooting Your Device
Does not work: read only device!
how you’ve managed to get rid of read only device?
Hi Traiii,
You can root your smartphone to get rid of read only device.
Hi,
Kindly guide me how to root the android smartphone to get rid of read only device, so that i can edit the host file.
I have followed the steps explain in the above but it failed due to read only access.
Kindly guide me on this.
Thanks,
hi suresh,
can you tell me your device’s model number? so that we can get best possible solution to root your smartphone.
Hi Bhavesh Sondagar,
Kindly note the model no of my mobile device.
samsung
Device name: Galaxy J7
Model number: SM-J7OOF
Android version: 5.1.1
Let me know for more details if required.
Thks
you should have mentioned the prerequisite: “rooted device” in the first sentence.
I have to thank you for the efforts you’ve put in writing this blog.
I really hope to see the same high-grade content from you later on as
well. In truth, your creative writing abilities has motivated me to get my very own site now 😉
Hi sir… I cant open my gooleplaysevices also goole apps store. My device is already been rooted . but i cant edit nor delete that “host file” ialways got the message “file is read only.. Thanks in advance