How to Edit the Hosts File on Android (and Block Web Sites)

how-to-edit-the-hosts-file-on-android-and-block-web-sites photo 1

Whether you want to prevent your child from accessing Facebook or are simply sick of the advertisements that litter webpages, a custom hosts file can come in handy.

Note: This requires a rooted Android device.

how-to-edit-the-hosts-file-on-android-and-block-web-sites photo 2

How to Edit the Hosts File on Android

The easiest way to edit the hosts file on your device is to use the Android Debug Bridge, so go ahead and set it up. Once you’re done, 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.

how-to-edit-the-hosts-file-on-android-and-block-web-sites photo 3

Once the command prompt opens run the following command to see what devices are attached to your PC.

adb devices

how-to-edit-the-hosts-file-on-android-and-block-web-sites photo 4

Next you need to download the host file from your device so you can edit it.

adb pull /system/etc/hosts F:\hosts

how-to-edit-the-hosts-file-on-android-and-block-web-sites photo 5

Then navigate to where you saved the file and open it with notepad.

how-to-edit-the-hosts-file-on-android-and-block-web-sites photo 6

Now comes the fun part: adding the host entries. Really, you can do anything you want for example, you can use your host file to block ads from appearing on websites instead of using an app like AdBlocker, or in our case we can just block a website like FaceBook by redirecting it to localhost – you will have to search around to get the exact domains to block. When you’re done adding the entries don’t forget to save the file.

how-to-edit-the-hosts-file-on-android-and-block-web-sites photo 7

Finally you will need ADB to push the file back to your device.

adb push F:\hosts /system/etc/

how-to-edit-the-hosts-file-on-android-and-block-web-sites photo 8

That’s all there is to it. Now I can’t browse to Facebook from my device.

how-to-edit-the-hosts-file-on-android-and-block-web-sites photo 9

More stories

Automate Your Phone or Tablet with AutomateIt

There are lots of tools that can be used to automate various tasks on your computer, and we have looked at how the likes of Wappwolf and IFTTT can help to automate your online life. AutomateIt brings very much the same idea to Android, making it possible to automate your phone or tablet in a variety

Geek School: Learning Windows 7 – Managing Disks

Hard Drives: every computer running Windows has them and none can function without them. They house all our data, so we should set them up correctly. Read on to learn more about how to use RAID to protect your data.

How Can I Secure a Laptop with no Security Cable Slot?

Historically laptops included a slot in the side for attaching security cables–as seen in the photo here–but increasingly more slender laptops like ultrabooks are omitting the lock-slot from their case design. How do you properly secure a laptop without one?

How to Open Task Manager Quickly with the Keyboard

At least once a week, my best friend asks me “What’s that keyboard shortcut for Task Manager” again? And then I respond with CTRL + SHIFT + ESC, and then he tells me I should write up a tip about it. So… that’s what I’m doing.

Remove Your PC’s Recovery Partition and Take Control of Your Hard Drive

If you’ve bought a PC with Windows 8 or 10 installed, you may be surprised to find that there is not quite as much storage space available as you would expect based on the size of your hard drive. This could be for a couple of reasons, including a Windows recovery image occupying several gigabytes.