How to connect to localhost from VS Android Emulator
Asked Answered
C

3

15

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.

Cameroncameroon answered 13/1, 2016 at 23:49 Comment(6)
have you tried. 10.0.2.2:80 ?Semiconductor
Yes. Neither 10.0.2.2:80 or 10.0.2.2:8080 works.Cameroncameroon
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.Semiconductor
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.Cameroncameroon
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?Semiconductor
The localhost is accessible from the browser of a VS Android Emulator which is running KitKat.Cameroncameroon
T
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

Trimaran answered 16/6, 2016 at 8:37 Comment(5)
You just did not mention that two adapters in a right order requiredAby
one is virtual and one is belong to my machineTrimaran
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 workAby
Now 169.254.80.80 works which did not work before. And 192.168.1.111 does not work which worked beforeAby
It does not because I set 192.168.1.111 as constant for MAC address of my PC in router DHCP settings.Aby
H
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.

Howdoyoudo answered 15/1, 2016 at 22:11 Comment(1)
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: #28262776Inguinal
A
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

Allina answered 15/11, 2018 at 9:44 Comment(2)
but then debugger will connect to debugger agent. because it runs on 10.0.2.2. you will get this error message [mono] debugger-agent: Unable to connect to 10.0.2.2: xxxxKetene
What is Your port number ?Melanoma

© 2022 - 2024 — McMap. All rights reserved.