• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
B2G OS
  1. MDN
  2. Archive of obsolete content
  3. B2G OS
  4. Developing Firefox OS
  5. Modifying the hosts file

Modifying the hosts file

In This Article
  1. Preparing your phone
  2. Steps in the terminal

Sometimes you need to edit the hosts file on your machine because of an attack, to block unwanted connections, to redirect requests to a specific IP, etc. This article explains how to modify the hosts file of your Firefox OS phone. It is located under for example /system/etc on Linux, and just etc/ on newer Mac OSX versions.

Preparing your phone

On the phone, go the Developer settings panel and check:

  • "Remote Debugging" (in Firefox OS 1.4 and above, select "ADB and Devtools" from the select menu)
  • "Console Enabled"

Then plug your phone to your computer.

At this point the steps for modifying the hosts file are the same as for Android. Android developers will quickly settle into the swing of things.

Steps in the terminal

  1. Open a terminal window.
  2. Remount the /system partition on the device to get read-write permissions
    adb remount
  3. Get the hosts file on your computer
    adb pull /system/etc/hosts /tmp
  4. Modify the hosts file in /tmp/hosts as needed and save the file. For example:
    127.0.0.1         localhost
    ip.to.re.direct   hostName
  5. Push the modified hosts file to the device
    adb push /tmp/hosts /system/etc/hosts

This is it; your hosts file should now be updated.

Note: To learn more about ADB? Have a look at the ADB documentation.

 

Document Tags and Contributors

Tags: 
  • Firefox OS
  • hosts
 Contributors to this page: chrisdavidmills, Jeremie, Audrey
 Last updated by: chrisdavidmills, Feb 27, 2017, 2:58:46 AM
See also
  1. Build and install
    1. Build and install overview
    2. B2G OS build process summary
    3. Build prerequisites
    4. Preparing for your first build
    5. Building B2G OS
    6. B2G installer add-on
    7. Building B2G OS for Flame on Mac OS X
    8. Choosing how to run Gaia or B2G OS
    9. Compatible Devices
    10. Installing B2G OS on a mobile device
    11. Creating and applying B2G OS update packages
    12. Building and installing FOTA community builds
    13. B2G build variables reference sheet
  2. Porting B2G OS
    1. Porting overview
    2. Porting basics
    3. Porting on CyanogenMod
  3. Developing Gaia
    1. Developing Gaia overview
    2. Running the Gaia codebase
    3. Run Gaia on desktop using Mulet
    4. Understanding the Gaia codebase
    5. Making Gaia code changes
    6. Testing Gaia code changes
    7. Submitting a Gaia patch
    8. Gaia build system primer
    9. Different ways to run Gaia
    10. Make options reference
    11. Gaia tools reference
  4. B2G OS APIs