Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

WebException: Error: ConnectFailure (No route to host)

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri("http://10.0.xx.xx/myService.aspx"));
request.ContentType = "application/json";
request.Method = "GET";
var response = request.GetResponse();

This code works fine from a visual studio console app but when running from xamarin studio and the android emulator it results in the exception:

Any help appreciated. Is this a licencing thing? Just running trial

more detail attached


  • MihaMarkicMihaMarkic SI ✭✭✭✭

    I'd say that your device lives on different IP address that your computer does and that IP is unreachable from it.
    Try accessing that IP from within a browser on the device and you'll see.


    Hey, Guys, this error occurs due to lack of data connection.Please check data is ON

  • TBMSamTBMSam Member ✭✭
    edited December 2018

    okay @MihaMarkic but what to do? how to fix/change this so that they have the same ip or whatever?

  • knudmtknudmt Member ✭✭

    Android routes things a little differently. But you should take note of whether you are running IIS Express or not.
    The problem is that the Android emulator maps to, not to localhost. So configure your web server to server on and not localhost:portnumber. That should do it.

  • For someone reading it now. The answers given above worked for me. Instead of accessing the web api from local machine, I pushed the service to cloud and then device had no issue in accessing it. Make sure wifi is enabled on the device.

Sign In or Register to comment.