System.Net.Sockets.SocketException: Connection refused

SanjayTejaniSanjayTejani USMember ✭✭✭
edited November 2016 in Cross Platform with Xamarin

Hi All,

When I call WebApi I am getting an error like

{System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused

Can any one help me to resolve this issue.

Best Answers


  • SanjayTejaniSanjayTejani USMember ✭✭✭
    edited November 2016


    My device or emulator are connected with internet.

  • VulcanVulcan TWMember ✭✭✭


    So, your problem is solved?

  • AlanStrattonAlanStratton USMember ✭✭

    I was able to work around this problem in this manner:

    1) Install IIS on my local machine, and deploy my WebAPI project to that.
    2) Change my Url I use for connecting to the WebAPI from localhost to the hostname of my machine
    3) Ensured that the Android Permissions allowed "INTERNET"

    The Virtual Machine for the Android emulator needs something different than localhost due to the way it is networked.

  • anish_palanish_pal INMember ✭✭

    consuming web API and i am connected with internet but still getting same exception..
    "System.Net.Sockets.SocketException: Connection refused"

  • @anish_pal

    If you're calling the rest api on hosted your local machine/computer that is running the emulator, check that you are using the url "" instead of "localhost". Hope it helps.

  • RobertAuerRobertAuer USMember ✭✭

    @anish_pal Did you get it to work? I'm hitting the same issue.

Sign In or Register to comment.