[Q] lost etc/hosts file

Search This thread

Bdvs

New member
Sep 9, 2012
3
0
hello everyone
I have a t-mobile note 2 rooted and i was having problems with my play store and deleted my hosts file by mistake i tried making a new one with root explorer but it fails is there anything els that i can do to get it back when i reset my phone the play store is gone and i don't know what to do any help would be great.
 

ciphercodes

Senior Member
Oct 25, 2012
488
243
hello everyone
I have a t-mobile note 2 rooted and i was having problems with my play store and deleted my hosts file by mistake i tried making a new one with root explorer but it fails is there anything els that i can do to get it back when i reset my phone the play store is gone and i don't know what to do any help would be great.

Do you have access to a system with adb or heimdall ?
If not
You can create a new file(text) named hosts under /etc/system/ with the following line
127.0.0.0 localhost
You can set the permissions of this file to 0644 via root explorer or using Terminal Emulator:
----
cd /system/etc
chmod 644 hosts
---
Never used root explorer but there has to be a GUI option somewhere in it.
You will have to mount the /system to read-write mode in root explorer in order to make any changes.
Once you have created the file, reboot the phone and see if it works, if not then manually delete all files under /system/data/dalvick-cache.
Be careful before deleting any file, make sure you browse to /system/data/-dalvick-cache directory and select all files and then delete them.
 
Last edited:

Bdvs

New member
Sep 9, 2012
3
0
Do you have access to a system with adb or heimdall ?
If not
You can create a new file(text) named hosts under /etc/system/ with the following line
127.0.0.0 localhost
You can set the permissions of this file to 0644 via root explorer or using Terminal Emulator:
----
cd /system/etc
chmod 644 hosts
---
Never used root explorer but there has to be a GUI option somewhere in it.
You will have to mount the /system to read-write mode in root explorer in order to make any changes.
Once you have created the file, reboot the phone and see if it works, if not then manually delete all files under /system/data/dalvick-cache.
Be careful before deleting any file, make sure you browse to /system/data/-dalvick-cache directory and select all files and then delete them.
I have adb access how would i do it with adb
root explorer wont let me make a text file
 

ciphercodes

Senior Member
Oct 25, 2012
488
243
I have adb access how would i do it with adb
root explorer wont let me make a text file
1) Using text editor create a text file named "hosts" with the following contents:
---
127.0.0.1 localhost
---
If you are on windows make sure you remove the file extension.
2) Connect phone via USB and open command prompt or shell. Make sure USB Debugging is checked under developers options.
3) Check if adb detects your device by typing: adb devices , you should see your device listed, if not please check if your phone has correct USB drivers.
4) Now push the file you created to your phone with this command : adb push /path/to/file/hosts /sdcard/hosts
example: adb push C:\tmp\hosts /sdcard/hosts
5) Now log in to your phone by typing adb shell
6) Switch to super user by typing: su , grant permissions when asked by SuperSU.
7) Mount system in read-write mode by typing: mount -o remount,rw -t yaffsw /dev/block/mtdblk3 /system
8) Move the hosts file to /system/etc by typing: mv /sdcard/hosts /system/etc
9) Browse to /system/etc by typing: cd /system/etc
10) Change file owner and group by typing: chown root:root hosts
11) Change file permissions by typing: chmod 644 hosts
12) Mount system back to read only by typing: mount -o remount,ro -t yaffsw /dev/block/mtdblk3 /system
13) Delete dalvik cache by browsing to cd /data/dalvik-cache and then type rm -f *.dex
14) type exit two times to exit.
15) Reboot phone and it should work.

I believe there might be an easy way or an apk which does this but I haven't tried it.
 

Bdvs

New member
Sep 9, 2012
3
0
play store

1) Using text editor create a text file named "hosts" with the following contents:
---
127.0.0.1 localhost
---
If you are on windows make sure you remove the file extension.
2) Connect phone via USB and open command prompt or shell. Make sure USB Debugging is checked under developers options.
3) Check if adb detects your device by typing: adb devices , you should see your device listed, if not please check if your phone has correct USB drivers.
4) Now push the file you created to your phone with this command : adb push /path/to/file/hosts /sdcard/hosts
example: adb push C:\tmp\hosts /sdcard/hosts
5) Now log in to your phone by typing adb shell
6) Switch to super user by typing: su , grant permissions when asked by SuperSU.
7) Mount system in read-write mode by typing: mount -o remount,rw -t yaffsw /dev/block/mtdblk3 /system
8) Move the hosts file to /system/etc by typing: mv /sdcard/hosts /system/etc
9) Browse to /system/etc by typing: cd /system/etc
10) Change file owner and group by typing: chown root:root hosts
11) Change file permissions by typing: chmod 644 hosts
12) Mount system back to read only by typing: mount -o remount,ro -t yaffsw /dev/block/mtdblk3 /system
13) Delete dalvik cache by browsing to cd /data/dalvik-cache and then type rm -f *.dex
14) type exit two times to exit.
15) Reboot phone and it should work.

I believe there might be an easy way or an apk which does this but I haven't tried it.

Thanks for all your help i got the hosts file in to system/etc folder but my play store is still not working i get a pop up that play store has stop working so i cleared cache for play store, play services and google framework and its still not working
any ideas thanks again
 

ciphercodes

Senior Member
Oct 25, 2012
488
243
Did you delete dalvik cache ?

Sent from my SGH-T889 using xda app-developers app
 
Last edited: