

Most servers you run locally are started on 127.0.0.1:PORT, where 127.0.0.1 normally corresponds to localhost. This also means you need to make sure that your Android device is connected to the same network as the computer running the server you're trying to reach. Using the 0.0.0.0 address allows your sever to be accessible to connections outside of the host machine such as your local area network (LAN). You'll need to make sure that your web server is started on 0.0.0.0:PORT instead of localhost/loopback ( 127.0.0.1). If you're using a physical Android device and want to access a web app running on localhost of your computer, then it's a bit trickier. Otherwise, the page will fail to load when you click on "inspect."Īccessing Localhost inside Physical Android Device However, as mentioned in my article on accessing localhost inside an Android emulator, you'll have to use 10.0.2.2:PORT instead of localhost:PORT if you're using an Android emulator. You can debug websites running locally on your computer using Chrome DevTools and an Android emulator.

Accessing Localhost inside Android Emulators

If you want to access localhost of a server running on your computer inside an Android emulator or physical Android device, please continue reading the next couple sections. You can alter text and have the changes appear on your Android device or emulator in real time! Try using the URL of my website or common websites you visit. If we click on "inspect," then it will open up developer tools in the URL you specified. You can either use the search box, as seen in the image above, to navigate to a URL, or you can navigate to a URL directly from Chrome in your Android device or emulator. To see these options appear, we first need to make sure we have Chrome opened in the Android device or emulator. Notice that in the image above, I have a few options available: inspect, pause, focus tab, reload, and close. Android emulators should pair by default. If you don't see your physical device appear, then that means your device might not be paired properly with your computer. In my case, I'm using an Android simulator. You should see a list of all of your connected devices.
