NOTE: Of late, I have been getting requests for very trivial problems that many of you are facing in your day-to-day work. This blog is not to solve your "project" problems - surely not a "Support" site.
I just love to share my knowledge in my spare time and would appreciate any questions or feedback on the articles and code I have shared. I also do appreciate thought-provoking questions that would lead me to write more articles and share.
But please do not put your day-to-day trivial problems here. Even if you do, you most probably would not get a response here.

Search This Blog


Monday, 14 November 2011

Localhost Access in Android Emulator

This is a small tit-bit I discovered today:

If you want to access your localhost through the Android Emulator - you need to use the IP Address unlike how we do on the web browsers on our desktops where we access the local host as or 'localhost' itself.

This information is useful if for testing purposes you have locally installed a webserver and put a few HTML pages or if you have locally hosted web services - say REST Services that need to be invoked through a URL like this: http://localhost:8080/rest/hello, then, use the above mentioned IP address and you will be able to access your service or webpage through the emulator.

Or you could simple use your own IP address like - whatever yours is. If you do a "ipconfig" in a windows command prompt, you will know what your IP address is. (one of the ways to find it out). However, there is one disadvantage with this method if your IP is allocated to you dynamically on your network. This will keep changing. In such a case, using will be the equivalent of which will not change for the localhost.

Hope this helps.


  1. More details here:

  2. You've got a nice blog. The above post is something which many of starters would be glad to know. Only thing is, when running on MAC, since it comes with inbuilt local server, knowledge of console is must along with 3rd part mysql editors for convenience. Alternatively, MAMP is also an option.

    Glad to be here and sure will be back.

    Just a small introduction, I am prajyot mainkar,i am an android developer as well :-). .

  3. Thank you so much for the information shared, I tried with the IP mentioned: but it gives me Protocol not found :1 exception any solution to this one?

  4. Your articles don’t beat around the bushes exact t to the point.
    one click root news

  5. Before u trying this make sure your firewall is turned off.

  6. First of all, this is a great blog and I would like to thank you for all the information you've been sharing throught it.

    Now, for people using Genymotion ( ) as their emulator, it would be worth noting that the IP address to connect to localhost is instead of

    Keep up the good work.

  7. hey aditya i have a doubt in phonegap see i made an app its working in emulator .but not working in android phone .in android phone design is coming but not calling localhost webservice can u help me