While we are developing a mobile app that talks to an API on our own, we may want to just put a breakpoint in an API call and see what happens.

Although the best way to test and API is with programs like Postman, there are occasions where we need some context about when a call is made and for what reason.

This looks difficult considering the fact that we are developing the API in the computer’s localhost, which is different than mobile’s localhost. We usually have an intuition here because we think that, being in the same network, there should be a way to access the computer. If you thought that, then you were right.

#1. Handle with Windows Firewall

We may need to add the used port to the exceptions of the Windows Firewall. This is as simple as going to Windows Firewall with Advanced Security (ask it to Cortana), and, in Inbound Rule, add a new one to the chosen one, through TCP.  I haven’t told you the port you have to add, but that is going to depend on the one your program (where you deploy your app, I mean) is going to use.

#2.  Set IIS Express

If you are developing with Visual Studio, you will have to edit the config file of the project (project/.vs/config/applicationhost.config), adding the bold line and, yes, you probably have to change that IP address with the one you have (cmd with ipconfig).

<bindings>
    <binding protocol="http" bindingInformation="*:41169:localhost" />
    <binding protocol="http" bindingInformation="*:41169:192.168.1.101" />
</bindings>

Your best shot to find where to add it will be making a Ctrl+F with “localhost”.

You will also have to “Run as administrator” the Visual Studio instance the next time you want to test this.

#3. Final checks

The quickest way to know if you can access to the running API will be trying to reach the IP address from your mobile phone, typing the URL in the browser and check if you are watching the same you would look if you write localhost in the computer.

Trust me, this is a good tip because it is going to save you some minutes just in case you forgot to do some of the steps. Compare typing a URL in a browser with trying to launch the mobile app (especially if you are debugging it to).

Once you’ve checked you can reach the computer, now you can debug both the API and the mobile app at the same time.