Skip to content

Add guide how to connect to any service hosted at localhost from real device connected through Visual Studio #8379

@janseris

Description

@janseris

Description

For MAUI run on Windows, it is easy to access localhost, it's simply localhost.
For MAUI run on Android emulator, simply replace localhost with 10.0.2.2
This is from this guide: https://docs.microsoft.com/en-us/xamarin/cross-platform/deploy-test/connect-to-local-web-services and it works fine.

For SQL Server Express used from emulator there is a nice tutorial here which works (the most important part is to open TCP/IP connections in the server config) (however the new Microsoft.Sql.Data client does not work on Android or works only for newer Android (depending on the version)):
https://www.youtube.com/watch?v=xNmIdFjXzl4

But for Android device which runs MAUI application attached via Visual Studio debugger? 10.0.2.2 doesn't work.

How to please connect to a service hosted on localhost?
Not only HTTP but also TDS or any other protocol.

There is no guide for Android device afaik. But testing must be done also on a real device!

Thank you.

Public API Changes

Add documentation on how to access localhost from Android device when running via Visual Studio (both Debug and Release).

Intended Use-Case

Simulating production environment with MAUI app,

Possible workaround

  • to connect localhost to Android device, if these are on the same network, a temporary private IP can be exposed by localhost and ports with applications open. However this is not a robust solution and router can frequently change the private IP addresses assigned to devices (having a static private IP address in a network is not guaranteed)

VS bug #1745020

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-docsConceptual docs, API docs, Samplesproposal/opens/move-to-vs-feedbackTells automation to ask the person to use VS Feedback to report the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions