Last Updated on November 30, 2018 by Dave Farquhar
Someone asked me how to edit a hosts file in Android, which was a trick I used to recommend in Windows. Editing a hosts file is really two questions: Do you really want to edit it, or do you want to replace it?
If you want to edit it, the answer, as usual, is a cliché: There’s an app for that. Root the device, search the Play store for “hosts,” and try the various editors to see which one you like the most.
If you want to replace it, the easiest way to do so is to download the file using a computer–a good one to use is http://www.malwaredomainlist.
If you edit the file on your computer before writing it to your Android device, be sure to use a text editor that will leave the line breaks in Unix format.
I don’t really recommend messing with hosts files on Android if you can avoid it. It’s bad form, and you risk your antivirus software flagging it as a hosts file hijack. Worse yet, if you get an actual hosts file hijack, you may not find it if, like some people, you have a multi-megabyte hosts file full of junk. You can probably get the benefits you seek by using Cleanbrowsing’s DNS servers, with a lot less hassle.
David Farquhar is a computer security professional, entrepreneur, and author. He started his career as a part-time computer technician in 1994, worked his way up to system administrator by 1997, and has specialized in vulnerability management since 2013. He invests in real estate on the side and his hobbies include O gauge trains, baseball cards, and retro computers and video games. A University of Missouri graduate, he holds CISSP and Security+ certifications. He lives in St. Louis with his family.