File hosts on Android is a hidden system document that manages the mapping of domain names (for example, google.com) to IP addresses. Editing it allows you to block ads, redirect traffic or test web projects locally. However, access to this file is limited: manufacturers hide it deep in the system partition, and changes without the correct rights are reset after a reboot.

Many users encounter problems when trying to change hosts โ€”from lack of root access to saving errors. In this article, we'll break down file editing (including methods without root), explain why changes may not apply, and provide a checklist for checking the result. We will pay special attention all current methods editing a file (including methods without root), explain why the changes may not be applied, and provide a checklist for checking the result. We will pay special attention security risks to how to avoid common mistakes when working with system files.

โš ๏ธ Important: Editing system files can disrupt the operation of the device or lead to loss of warranty. You perform all actions at your own peril and risk. We recommend that you create a backup copy of your data before you begin.

What is a hosts file and why edit it on Android

A file hosts is a text document that exists on all operating systems (Windows, macOS, Linux, Android). It works like a local "phone book" for Internet addresses: when you enter a URL in the browser, the system first checks hosts, and only then contacts DNS servers.

On Android, this file is located at the path /system/etc/hosts and by default contains only one active line: 127.0.0.1 localhost. Editing it allows you to:

  • ๐Ÿšซ Block ads and trackers โ€” redirecting advertising network domains to an โ€œemptyโ€ IP (0.0.0.0 or 127.0.0.1).
  • ๐Ÿ”— Test websites locally โ€” linking the domain to the IP of your test server.
  • ๐Ÿ”’ Bypass geo-blocking - replacing the IP of resources blocked in your country.
  • ๐Ÿ›ก๏ธ Protect from phishing - blocking known malicious domains.

However, on Android there are two key problems: 1) The file is located in a protected system partition, and without root access it cannot be changed directly. 2) Even after editing, changes may be reset due to the mechanism System-as-Root (used on new versions of Android) or OTA updates.

๐Ÿ“Š Why do you want edit hosts on Android?
Ad blocking
Testing sites
Bypassing blocking
Other

Method 1: Editing hosts via Root Explorer (root access required)

If your device has unlocked bootloader installed Magisk or another root manager, this method is the most reliable. You will need any file manager with root support (for example, Solid Explorer, FX File Explorer or Root Browser).

Step-by-step guide:

  1. Open the file manager and give it root access when prompted.
  2. Navigate to the path /system/etc/ (or /system/system/etc/ on some firmware).
  3. Find the file hosts, click on it and select "Open with" โ†’ "Text editor".
  4. Add your rules to the end of the file. Example for blocking ads:
    0.0.0.0 ad.mob.com
    

    0.0.0.0 tracking.example.net

    127.0.0.1 malicious-site.ru

  5. Save the changes and reboot the device.

โš ๏ธ Attention: On some firmware (for example, MIUI or ColorOS) file hosts can be a symbolic link. In this case, edit the original file to which it points (you can find out the path through the command ls -l /system/etc/hosts in Terminal Emulator).

Create backup copy of the original hosts file|Check free space in the /system partition|Disable antivirus (may block changes)|Make sure the battery is charged >50%-->

Method 2: Using ADB (without root, but with restrictions)

If root access is not present, but enabled USB debugging, you can try change hosts via Android Debug Bridge (ADB). This method does not work on all devices (especially with Android 10+), but itโ€™s worth a try.

What you will need:

  • ๐Ÿ–ฅ๏ธ A computer with installed ADB Tools.
  • ๐Ÿ“ฑ Android smartphone with USB debugging enabled (Settings โ†’ About phone โ†’ Build number (7 taps) โ†’ For developers โ†’ Debugging USB).
  • ๐Ÿ”Œ USB cable (preferably original).

Instructions:

  1. Connect the phone to the PC and run in the command line:
    adb devices

    Make sure that the device is detected (its serial number should appear).

  2. Download the file hosts to your computer:
    adb pull /system/etc/hosts C:\hosts_backup
  3. Open the downloaded file in Notepad or Notepad++, make changes and save.
  4. Download the file back in remount mode (temporary mount of the system for recording):
    adb remount
    

    adb push C:\hosts_backup /system/etc/hosts

    adb reboot

โš ๏ธ Attention: On devices with Dynamic Partitions (Android 10+) command adb remount may does not work. In this case, try the alternative method via adb shell:

adb shell

su

mount -o rw,remount /system

echo "0.0.0.0 ad.example.com" >> /system/etc/hosts

mount -o ro,remount /system

exit

adb reboot

Why are hosts changes reset after a reboot?

On new versions of Android (10+), the system restores the original files from the image system.img at boot. This is part of the mechanism. protection dm-verity. In order for changes to be saved, you need to either disable verification (unsafe) or use modules Magisk (for example, Systemless Hosts).

Method 3: Applications for editing hosts without root

If you do not have root access and ADB did not help, you can try specialized applications. They work on the principle VPN interceptor: they create a local proxy server that emulates changes in hosts. The downside is that traffic passes through additional software, which can slow down the connection.

Top 3 applications (2026) year):

Application Working principle Pros Cons
Hosts Editor VPN interceptor + local DNS Simple interface, ready-made block lists Requires constant VPN operation, may be slow
Blokada Ad blocker with support for custom hosts Open source, no root Limited functionality in the free version
DNS66 Local DNS server with support for hosts Without root, blocks at the DNS level Complicated for beginners

๐Ÿ”น How to use (using an example Hosts Editor):

  1. Install the application from Google Play or F-Droid.
  2. Open it and grant permission to create a VPN connection.
  3. In the "Hosts" section, add your rules or import a ready-made list (for example, StevenBlack).
  4. Activate the VPN switch in the application.

Important: Applications without root do not change the real hosts file, but emulate its operation. This means that blocking will only work when the VPN connection is active.

๐Ÿ’ก

If you need to block advertising in a specific application (for example, in a game), check whether it supports work via VPN. Some apps (for example, banking) block traffic when a VPN is detected.

Method 4: Editing hosts via TWRP Recovery (for advanced)

If you have custom recovery installed on your device (TWRP), you can edit hosts directly through it. This method is suitable for devices without root, but unlocked. bootloader.

Step-by-step guide:

  1. Turn off the phone and boot into TWRP (usually Power + Volume Up).
  2. Go to section Advanced โ†’ File Manager.
  3. Find the file /system/etc/hosts, click on it and select "Edit".
  4. Make changes, save the file and reboot into the system.

โš ๏ธ Attention: V TWRP no syntax checking. If you make a mistake in the file format (for example, forgetting a line break after the last entry), it can lead to bootloop (load loop). Always check the file before saving!

๐Ÿ”น Alternative: If you are afraid to edit manually, download the finished file hosts to your computer, edit it, and then TWRP replace the original file (Mount โ†’ System, then copy the new file to /system/etc/).

Method 5: Magisk modules for system editing hosts

If you have Magiskinstalled, the most reliable way is to use modules that automatically apply changes to hosts when the system boots. This bypasses restrictions dm-verity and guarantees the safety of changes after a reboot.

Best modules (2026):

  • ๐Ÿ›ก๏ธ Systemless Hosts โ€” allows you to edit hosts without changing the system partition.
  • ๐Ÿ”„ Hosts File Editor for Magisk โ€” adds a graphical interface for managing records.
  • ๐Ÿšซ AdAway โ€” ad blocker with support for custom hosts lists.

How to install:

  1. Download the module (file with extension .zip) from XDA Developers or GitHub.
  2. Open Magisk Manager, go to section Modules โ†’ Install from storage.
  3. Select the downloaded file and wait for installation.
  4. Reboot the device.

๐Ÿ”น Settings Systemless Hosts:

After installing the module, the file hosts will be available along the path /data/adb/modules/systemless_hosts/system/etc/hostsEdit it through any root manager.

๐Ÿ’ก

Modules Magisk is the only way to guarantee that hosts changes are saved after a system update (OTA).

Typical errors and how to fix them

Even after successful editing hosts here are the most common problems and their solutions:

Problem Possible cause Solution
Changes are reset after reboot Mechanism dm-verity or OTA update Use modules Magisk or disable checking (not recommended)
Sites are not blocked Wrong file format or DNS cache Check the syntax (every line โ€” IP address + domain). Clear the cache: adb shell ip route flush cache
Error saving file Insufficient rights or partition /system in mode ro Run mount -o rw,remount /system before editing
The device does not boot (bootloop) Error in the file hosts or damage to the system partition Boot in TWRP and restore the original file

โš ๏ธ Attention: If after editing hosts the sites stop opening or the Internet connection is lost, check the file for typos. For example, the line 0.0.0.0 google.com will block access to Google. To get everything back, delete the added entries or. restore the original file.

๐Ÿ”น Checking functionality:

After applying the changes, open Terminal Emulator and execute:

ping google.com

If the response contains IP 0.0.0.0 or 127.0.0.1, then the blocking is working.

Security: risks of editing hosts and how to minimize them

Changing system files is always associated with risks. Here's what can go wrong and how to avoid it:

  • ๐Ÿ”“ Loss of warranty โ€”manufacturers. (for example, Samsung or Xiaomi) may void the warranty if changes are detected in the system partition. Solution: Use non-root methods or restore the original file before contacting the service.
  • ๐Ÿ›ก๏ธ Security vulnerabilities โ€”incorrect entries in hosts can redirect you to phishing sites. Solution: Check the sources of ready-made block lists (for example, StevenBlack or OISD).
  • ๐Ÿข Slowing down the Internet โ€”when using VPN interceptors, traffic passes through additional software. Solution: Disable the blocking module when it is not needed.
  • ๐Ÿ”„ Conflicts with others applications โ€”some apps (for example, Orbot or 1.1.1.1) may ignore local hosts. Solution: Configure DNS priority manually.

Critical information: On Android 12+, Google has introduced additional restrictions on changing system files via Read-Only PartitionsEven with root access, editing hosts may require disabling. verity i avb, which reduces the security of the device.

๐Ÿ”น Security recommendations:

  • Always create a backup copy of the original file hosts.
  • Do not block system domains (for example, googleapis.com), this may disrupt the operation of applications.
  • Regularly update block lists (outdated entries may not be effective).

๐Ÿ’ก

To check which domains are blocked in real time, use the application NetGuard or PCAPdroid for analysis traffic.

FAQ: Frequently asked questions about editing hosts on Android

Is it possible to edit hosts without root and a computer?

Yes, but with serious limitations Applications like Hosts Editor or Blokada emulate work hosts via VPN, but do not change the real file. Without root and ADB, full editing of the system file hosts is impossible.

Why are changes not saved after editing hosts via ADB?

On new versions of Android (10+) partition /system is mounted in read-only mode (ro), and the command adb remount does not work. Solutions:

  • Use Magisk for system changes.
  • Try an alternative method: adb shell โ†’ su โ†’ mount -o rw,remount /system.
  • On some firmware (for example, One UIyou need to disable dm-verity.

How to return the original hosts file if the device does not boot?

If after editing hosts has bootloop, do the following:

  1. Boot into TWRP Recovery.
  2. Connect your phone to the PC and copy the original file hosts (for example, from another device or from a backup) to /system/etc/.
  3. Set the correct rights: chmod 644 /system/etc/hosts.
  4. Reboot.

If TWRP no, you will have to reflash the device via Fastboot.

Does blocking via hosts work in games and applications?

Depends on how the application processes DNS requests:

  • ๐ŸŸข Works: In browsers, most sites, some games (for example, with advertising through AdMob).
  • ๐Ÿ”ด Does not work: In applications that use hardcoded IP (for example, some banking apps or Netflix).
  • โš ๏ธ Partially works: In games with protection against cheats (for example, PUBG Mobile or Genshin Impact), the blocking may work unstable.

For testing, use Packet Capture or HTTP Toolkit.

Is it possible to edit hosts on Android TV or Fire TV Stick?

Yes, but with nuances:

  • Android TV: The methods are the same, but unlocking the bootloader is required (on most devices this is more difficult than on smartphones).
  • Fire TV Stick: You need to get root through FireOS-specific exploits (for example, FireStickRoot). data-i="315">easier to use

To block ads on Fire TV easier to use Pi-hole on a router.