IIS Express and Android Studio connection issues

If you are getting a following like error when you are trying to connect to a Microsoft Web Service or whatever server point that is under IIS Express you might encounter the following error:

failed to connect to /127.0.0.1 (port “Your port number here”): connect failed: ECONNREFUSED (Connection refused)

The error above is due to a loopback problem. What you need to do is do some configurations.

  1. Find your applicationhost.config file under your documents(usually): C:\Users\”Your account name here”\Documents\IISExpress\config
  2. Then find your web service binding information see the example below(the sample in the green color, the red color binding is what is by default configured).
  3. Add the IP address and the port to which you want to connect at from android studio. The IP address has to be your development machines IP address.
  4. Also you need to add new rules to your windows firewall that allows your ports through which you wish the connection to be done.
  5. You may need to run Visual Studio in Administrator mode

<sites>

<site name=”MyFitnessTrackerWebAPI(1)” id=”17″>
<application path=”/” applicationPool=”Clr4IntegratedAppPool”>
<virtualDirectory path=”/” physicalPath=”C:\Users\Adrian Simionescu\Dropbox\MyFitnessTracker\MyFitnessTrackerWebAPI\MyFitnessTrackerWebAPI” />
</application>
<bindings>
<binding protocol=”http” bindingInformation=”*:52797:localhost” />
<binding protocol=”http” bindingInformation=”*:80:192.168.163.151″ />
<binding protocol=”http” bindingInformation=”*:52797:192.168.163.151″ />
</bindings>
</site>

</sites>

After this when you start up your webservice you should be able to access your service by address or host name. Also your IIS Express hosting information should look something in the this direction(based on the configuration above):

IIS express configurations

Advertisements

One thought on “IIS Express and Android Studio connection issues

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s