3

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 127.0.0.1 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

2
  • 3
    IMHO the only line required in the hosts file is 127.0.0.1 localhost. And of course the file must be world-readable. Try this: echo "127.0.0.1" > 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
    Commented Sep 11, 2014 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
    Commented Aug 2, 2015 at 13:49

3 Answers 3

1

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 8.8.8.8 to do this as 8.8.8.8 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.

0

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

1
  • 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
    Commented Dec 16, 2016 at 16:18
-1

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .