Localhost on device

MarijkeMarijke Member ✭✭

So I'm struggling to get an API working on my Android device that goes to localhost on my computer.
I use Visual Studio 2017 and I'm currently only testing for Android (no iOS).

What does work: I have found my IP-address from my pc and the right port, so when I enter the API on chrome on my phone it works, I get the info I wanted from the API. What also works is Xamarin Live Player, when I use the IP from my laptop, it gives the info from the API in the app, but one big issue here is that I can't log anything in Xamarin Live Player, which is very difficult to debug.

What I want to work but doesn't: Whenever I run the app on my device it gives an "System.Net.Webexception: Connection refused". My firewall is off and as I said, I can use the API in chrome but something goes wrong when I want to use it with the app. Same goes for the emulators from Visual Studio.

So, what can I do to get the local api to work on my device en emulators?


  • MarijkeMarijke Member ✭✭
    edited April 2018

    Don't mind this comment (why can't you delete a comment from yourself?)

  • AlmaJensen.9398AlmaJensen.9398 USMember ✭✭✭

    When testing one of my apps against an api I'm working on that hasn't been published yet and is being run from my local machine I tend to stick with debugging using the UWP version of my app. Local host just works so easily that way. I don't have to pull off other odd tricks to get say my android emulator to connect to my local api.

  • MarijkeMarijke Member ✭✭

    That is not an option anymore, I can't make a Windows project

Sign In or Register to comment.