[FIXED] Android emulator not connecting to localhost api


I have a Xamarin app and localhost API. I’m trying to connect to the API from the app, but it could not be found. I edited my applicationhost.config file and I tried localhost, and my IP address in the call, but it was not working.

So, how do I configure simple API access? (The API itself is working well)


There is simple workaround to connect Emulator & Simulator to localhost API.

Download third party software NgRok for Windows at any specific location of your PC. It just contains one executable file called ngrok.exe (you not need to install it).

Now execute your service on your preferred browser. Than follow below steps.

  • Open your ngrok.exe file path in command prompt

enter image description here

  • Keep your service url (take from your browser) with prefix ngrok http --host-header=rewrite and hit enter.

enter image description here

  • Now go to your browser where you have executed your service open new tab and type localhost:4040 than press enter –>Go to status there you will find your public url which you can use in your mobile application.

enter image description here

Note: Url structure should be like this public const string BaseUri = "https://8c56892f.ngrok.io/"; followed by / in last. Try not to append unnecessary /.


  1. You can debug services from one Visual Studio to another.

  2. Your url will be active until you close command prompt.

  3. In browser or command prompt track your requests status like Ok, Not found etc.

For more information visit this https://www.c-sharpcorner.com/article/exposing-local-web-server-to-internet-using-ngrok/

Hope it help you.

Answered By – R15

Answer Checked By – Timothy Miller (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published