How to connect Localhost in your MAC or Windows to your Android Device OR Android Emulator ?

By | December 7, 2014

The name “localhost” is just a loopback to your own computer.

1. ACCESSING LOCALHOST ON ANDROID DEVICE.

To access it on your Android Device, you need to find the computer’s IP address.

  • The most general way of finding this info, which works on both Mac and Linux, is to go into the Terminal and type “ifconfig” AND for Windows type “ipconfig” in the command prompt.
  • Look for either “en0” or “en1”, and under that entry look for the “inet” listing. It will be something along the lines of “192.168.1.100”.
  • When you find that address, that’s what you’ll want to put in your browser’s address bar or the URL in the code you want to call your MAC’s/Windows’ localhost.
  • On a Mac specifically,

    Go to System preferences/sharing OR just search on right top – remote management

    Make sure remote management is checked

Note : MAKE SURE THAT YOUR ANDROID DEVICE AND YOUR MAC/WINDOWS ARE ON THE SAME NETWORK OTHERWISE IT WILL NOT WORK. [EG : SAME WIFI NETWORK].

For Example in the Android code you can use like below and call a webservice that is residing in your local server, i.e your localhost.


 new HttpPost("http://192.168.0.101/your_localhost_folder/your_localhost_file.php");

2. ACCESSING LOCALHOST ON ANDROID EMULATOR.

You can have the same thing as described above for Android Emulator also as long as they are in same network.

But there are other options too…

You can check it in the post here.

One thought on “How to connect Localhost in your MAC or Windows to your Android Device OR Android Emulator ?

Leave a Reply

Your email address will not be published. Required fields are marked *