Accessing the host machine from your Android emulator

Call for donation: Nepal - Help Anil Joshi get a new home! Read the whole story »

I recently started a project where I develop an Android app (there will some posts later on ;) ) which accesses a remote server as its back-end, hosted on the Google Appengine.

When you develop, you normally start your Appengine server locally from within Eclipse (this has been very nicely configured by the Google Eclipse plugin wizard) s.t. it runs on localhost:8080. However when you try to access "http://localhost:8080" from your Android app, you will get a nice "Connection refused" exception. This is because localhost is the phone itself, basically the emulator.

After posting on SO, some gave me the hint of starting the appengine with you public IP address. This can be done in the Eclipse Run/Debug configuration under the "(x)=" arguments tab by passing the "--address="
Eclipse configuration
Fair enough, but this requires you to change the IP address in the run configuration every time you switch network + in the code (preferably in some properties file) where you access your webserver of course. Moreover when you develop in a team this is quite cumbersome.

There is however a far better solution. Thanks to a hint from a SO post, you can access your host machine with the IP address "". This has been designed in this way by the Android team. So your webserver can perfectly run at localhost and from your Android app you can access it via "".



Your ad here?