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. Edit hosts file on android device using Android Debug Bridge

Once the command prompt window opens, type “adb devices” without quotes to see what device is attached to your computer.

Edit Android Hosts File

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.

Opening Hosts FIle from Local 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

Modifying Hosts Files on Android Smartphones

You have modified the host file from your local drive of the computer. Now you will have to overwrite the hosts 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 will type facebook.com from the browser, it will not open.

Android Edit Hosts File
Android Edit Hosts File

You can also use the Hosts editor android app, which is available free on 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

Amazing Offer Available
Bhavesh Sondagar
Bhavesh Sondagar is editor in chief and webmaster of Theandroidportal Blog. You may reach him out @bksondagar on social media.

9 COMMENTS

    • 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

  1. 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 😉

  2. 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

Comments are closed.