Where is the Hosts File in Android?

Search This thread

saluk

Member
May 11, 2009
5
0
In my country some sites have been banned but most of us keep using them in pc's by changing hosts file in \Windows\System32\drivers\etc

adding ip strings like

207.200.100.5 shoutcast.com
207.200.100.5 www.shoutcast.com



I just wonder if there is someway to do this in android? If the answer is yes then my new question is "how"... :D

Thx for the answers...
 

mindrot

New member
Apr 18, 2010
1
0
question

hello there,

i'm a newbie and i don't know anything about programming. and i need a step by step guide to edit the host file. i have reached the file with file manager but i can't edit or replace it.

thanks.
 

gophergun

Senior Member
Feb 18, 2008
311
2
Should just be a matter of

adb pull /etc/hosts


Which will copy the file to the current directory, then make the necessary changes, then

adb remount
adb push hosts /etc/hosts

Anyone correct me if I'm wrong. If you don't have ADB set up, now would be a good time to do so; searching for "ADB for dummies" should help you with that.
 
Last edited:

cloverdale

Senior Member
Feb 9, 2009
1,596
147
Eugene, OR
www.jbthemes.com
I suggest nano if you have a ROM with this included (such as cyanogenmod). Then all you need to do is open the terminal and enter
Code:
 su
nano /system/etc/hosts

In this manner, one can do the edits straight from the phone terminal.
 

domenukk

Senior Member
Jan 11, 2010
823
31
Or download estrongs file manager, go to settings and set file system to "read write"(its in something like root settings or so). after that you can edit the file ;)
 

jcarrz1

Retired Recognized Developer
May 26, 2009
1,633
1,430
scienceprousa.com
I suggest nano if you have a ROM with this included (such as cyanogenmod). Then all you need to do is open the terminal and enter
Code:
 su
nano /system/etc/hosts

In this manner, one can do the edits straight from the phone terminal.

This guy knows his hosts. I have his file on my desktop and I push it into every rom I use.
 

DiskCrasher

New member
Oct 17, 2010
2
0
I've rooted my Droid and copied over a pre-populated hosts file to /system/etc that re-maps bad/ad sites to 127.0.0.1. However, when I open a terminal and ping one of the sites listed in the hosts file, it still comes back with the real IP and not 127.0.0.1. :confused:
 

RedWave31

Senior Member
May 9, 2007
685
288
Samsung Galaxy S21 Ultra
I do believe in Linux systems, the real hosts file is in root/data/data/
>The system/etc/ hosts file is empty, aka a decoy of some sorts....?

To view it, u may need "rootexplorer.apk" (as opposed to droidexplorer.exe, a windows vista program), as I couldn't get Astro to require SU

(Need to check this out, my own system may be different?)
 

Skrip037

Member
Apr 21, 2010
37
0
I do believe in Linux systems, the real hosts file is in root/data/data/
>The system/etc/ hosts file is empty, aka a decoy of some sorts....?

To view it, u may need "rootexplorer.apk" (as opposed to droidexplorer.exe, a windows vista program), as I couldn't get Astro to require SU

(Need to check this out, my own system may be different?)
If it is empty, it just means there aren't any hosts in it. /etc/hosts is the correct file.

I've rooted my Droid and copied over a pre-populated hosts file to /system/etc that re-maps bad/ad sites to 127.0.0.1. However, when I open a terminal and ping one of the sites listed in the hosts file, it still comes back with the real IP and not 127.0.0.1. :confused:
What exactly is the process you are using? Does it look like this?
capturearu.png


And when you pushed the hosts to your phone, what command did you use?
 
Last edited:

farmatito

Senior Member
Apr 28, 2009
569
130
Oppo Find 7a
I've rooted my Droid and copied over a pre-populated hosts file to /system/etc that re-maps bad/ad sites to 127.0.0.1. However, when I open a terminal and ping one of the sites listed in the hosts file, it still comes back with the real IP and not 127.0.0.1. :confused:

Where did you get the file from, a windows pc?
In this case you need to convert the end-of-line characters
from Dos to Unix ones. This could be done with nano editor
or with busybox's dos2unix command.
 

DiskCrasher

New member
Oct 17, 2010
2
0
Where did you get the file from, a windows pc?
In this case you need to convert the end-of-line characters
from Dos to Unix ones. This could be done with nano editor
or with busybox's dos2unix command.

That was it! I opened the hosts file in Notepad++ and converted it to UNIX format, then saved it back to my phone. Now blocked addresses are resolving to 127.0.0.1 as expected. No more ads or malware, yay!
 

kenanyan

New member
Oct 27, 2010
1
0
Converting hosts file to unix format is worked for me also ,i converted hosts file with notepad++ to unix format(edit>eol conversation>unix format) then copy it in etc ,overwrite(backup ojinal host file to sdcard first with copy command) ,no need to reboot phone
 

nuflood

Member
Jun 25, 2010
43
0
can't pull

Hi

I'm trying to pull the hosts file with adb or with android commander. the adb sais there isn't a file like that and the AC give me this when I try to copy:

Items count: 1
Items source: /system/etc/
Items destination: C:\android-sdk-windows\

Starting operation...

Coping file: hosts@
remote object '/system/etc/hosts@' does not exist


*** Operation complete! ***

What can I do?
thanks
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    Technically it's in /system/etc/hosts, /etc is a symlink.

    If you want to edit it, create a hosts file on your SD card and then cp from terminal with root privileges. Or you could adb push it from your computer.
    1