14

I am attempting to connect to the localhost of the machine from which I am booting a VS Android Emulator. I am able to successfully connect to the IIS Server when the Android version is Kitkat. However, I fail to connect when the VS Android Version is Lollipop or Marshmallow. The way I am connecting to the localhost is typing http://169.254.80.80 in the browser of the Emulator. As per http://developer.android.com/tools/devices/emulator.html#networkaddresses I should be able to connect to localhost using the IP address 10.0.2.2. However, this IP address doesn't seem to work for me.

dud5
  • 210
  • 1
  • 10
JayHawk
  • 275
  • 1
  • 5
  • 15
  • have you tried. 10.0.2.2:80 ? – Aizen Jan 14 '16 at 01:11
  • Yes. Neither 10.0.2.2:80 or 10.0.2.2:8080 works. – JayHawk Jan 14 '16 at 19:51
  • Have you tried checking the port 80 or 8080 if it is being used by other programs instead of the localhost that you're using. Is it an IIS server from an OS or IIS server on VS runtime? every IIS application that you have currently on IIS OS have different ports. So you might want to check which port are you trying to connect and application that is run by IIS. – Aizen Jan 14 '16 at 20:41
  • When I run the command "netstat -anb | findstr :80" I do not get any programs which are using the port 80. The IIS Server is run on my OS - Windows Server 2012 R2. When I open up the IIS Manager and take a look at the bindings of the Default Web Site I see the port assigned is 80. – JayHawk Jan 14 '16 at 21:45
  • if no one is using the port 80 doesn't that mean the application on your IIS is not running, even if it is assigned to it? Did you check if the application that is hosted by IIS is accessible on your Browser by that port? – Aizen Jan 14 '16 at 21:58
  • The localhost is accessible from the browser of a VS Android Emulator which is running KitKat. – JayHawk Jan 14 '16 at 22:33

3 Answers3

4

VS studio Emulator work very fine and fast

see the screen shot that how you can connect VS Emulator to localhoat

enter image description here

Adiii
  • 54,482
  • 7
  • 145
  • 148
  • You just did not mention that two adapters in a right order required – Andrii Dec 26 '16 at 23:40
  • one is virtual and one is belong to my machine – Adiii Dec 27 '16 at 06:12
  • I created VS Emulator 5.5-inch Marshmallow (6.0.0) XXHDPI Phone and it displays my IP for both Emulator Adapter #2 and Desktop Adapter #1. And connection does not work – Andrii Dec 29 '16 at 19:39
  • Now 169.254.80.80 works which did not work before. And 192.168.1.111 does not work which worked before – Andrii Dec 29 '16 at 21:55
  • It does not because I set 192.168.1.111 as constant for MAC address of my PC in router DHCP settings. – Andrii Jan 01 '17 at 13:07
3

The network addresses specified on http://developer.android.com/tools/devices/emulator.html#networkaddresses will not work for the Visual Studio Emulator for Android (well, except the very last one, which is the standard localhost IP address).

The address 169.254.80.80 is expected to work as a loopback to the host. There seems to be a bug regarding connectivity back to the host using that address on images running Lollipop (21) and above. I have logged a bug internally for this.

dud5
  • 210
  • 1
  • 10
  • If your still having issues connecting, may have to open a port on your firewall for you application to get through. see my answer here: http://stackoverflow.com/questions/28262276/visual-studio-2015-ctp5-android-emulator-loopback-to-localhost/39302048#39302048 – Mike Circuitry Sep 03 '16 at 14:47
2

The previous answer is perfect but Android studio 3+ emulator need to add IP and port on proxy under setting.

enter image description here

Md Imran Choudhury
  • 9,343
  • 4
  • 62
  • 60