i have a rooted device (Lenovo A3000-h) , and i had this issue of having my hosts file filled every now and then with additional lines (that sometimes blocked me from logging into my google play account) , and i used to manually edit the file and just erase these extra lines (keeping the line intact)

so yea everything was fine till this morning , i tried to access my google play and i couldn't so i tried to edit the hosts file one more time (as usual) but i noticed that the file size became 2.5mb although it has always been less than 0.5mb (170kb-250kb). anyways when i tried to edit it , the file wouldnt open giving me the message (not enough memory)

long story short i deleted the file and i noticed i had a hosts.bak file so i copied it and tried to connect but its taking forever and it's not connecting to the internet anymore.

hint : i took a copy of the file from my friend's "Samsung galaxy mega" phone and still it wouldn't connect

  • 3
    IMHO the only line required in the hosts file is localhost. And of course the file must be world-readable. Try this: echo "" > hosts && chmod 0644 hosts while in the directory the file should be in (/system/etc if I remember correctly – I cannot check at the moment).
    – Izzy
    Sep 11 '14 at 13:38
  • and i had this issue of having my hosts file filled every now and then with additional lines (that sometimes blocked me from logging into my google play account) you had a malware in your system that's adding these lines. Resolve that than you wouldn't have to fiddle with your hosts file.
    – Lie Ryan
    Aug 2 '15 at 13:49

You shouldn't need a hosts file to connect to the internet. It's used to map custom (private) IPs to a hostname. Deleting it shouldn't prevent your device from connecting to the internet, but I can think of one instance where it could. I have to explain some background info first to help you understand.

DNS is the protocol used to map a FQDN (fully quantified domain name) like play.google.com to an IP address. Android is Linux based, which uses a config file called resolv.conf to send DNS lookup requests to. If your cell carrier is populating that file with a FQDN instead of an IP address, the IP address of that FQDN would need to be listed in the hosts file so your phone will know how to look it up.

Look at the contents of /system/etc/resolv.conf. You should see one or two lines that begin with the word nameserver. If the data that comes after that word looks like a FQDN, then a corresponding entry needs to be in the hosts file too. If it's an IP address, then the cause of your connectivity issues is something else entirely. The first step is making sure your device can reach the internet. I usually do something like ping to do this as is one of Google's public DNS servers. If you can hit that server, then your issue is DNS related. If you can't, then there's something else unrelated to the hosts file preventing you from reaching the internet.


Copy the hosts file to etc folder and then install Adfree app, open it and click on Revert, and you are good to go.

  • I very much doubt that. Adfree can only revert to the backup it made. I don't see mentioned by the OP that Adfree was installed at all, so it could not have made such a backup. So what should it revert to then?
    – Izzy
    Dec 16 '16 at 16:18

Just delete your host file . Restart your phone and it will automatically connect to google .worked for me... dont try to edit it.

  • 1
    You might have been lucky then. AFAIK, the hosts file must at least contain the entry for localhost – as I already pointed out in my comment on the question itself more than 2 years ago.
    – Izzy
    Dec 16 '16 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.