Skip to: Site menu | Main content

Email Facebook LinkedIn Twitter Google

Blog...

Android Emulator Virtual Hosts with IIS

I do most of my development locally (using my local IIS webserver). My local webserver makes use of host headers to host multiple development sites on a single IP. After reading several articles and blog entries I was unable to find a good solution to allow using host headers with Android. The emulator can access the host machine out of the box on 10.0.2.2, but that will only show you the default IIS site.

Tom Deryckere's article (http://www.mobiledrupal.com/content/using-virtual-hosts-android-emulator) explains how to get host headers working on the emulator, but I didn't want to run terminal commands every time I launched the emulator or keep updating my host file across mulitple emulator images (I'm really lazy.)

The solution was pretty simple and I'm embarrassed that I didn't think of it before. I simply added another binding entry to a new port:

In IIS Manager:

  1. Select the site you want to access
  2. Click 'Bindings' in the right side Actions pane
  3. Click 'Add...' on the Site Binding dialog that is displayed
  4. Give the site a any valid port number that is not currently in use (example 9191)

Now in the Android emulator you can access your site using http://10.0.2.2:9191

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Thank you,
# Posted By Arun Prabhu | 3/25/14 3:12 AM
Could you put the line of the binding because I'm trying something is worng because it doesn't work. Thanks!
# Posted By Pedro | 11/24/15 9:51 AM
@Pedro, there's not really a line number per se. It's the IIS bindings dialog box. IIS Manager > Select the Site > Right-hand Actions column under 'Edit Site' > Bindings

Leave the IP Address set to All Unassigned, leave host name blank, enter any available port (i.e. 9191)

The Android emulator may have undergone several revisions since this entry so the default IP address may be different.

You're welcome to private message me and I will try to help.
# Posted By Jason Holden | 11/24/15 11:01 AM