published fresh until

.NET MAUI: reach a host API from Android emulators

Summary Point the emulator at the host alias, then distinguish listener, cleartext-policy and certificate failures before changing transport settings with HttpClient.BaseAddress

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: set HttpClient.BaseAddress to new Uri("http://10.0.2.2:5000/") only if the host API actually listens on HTTP port 5000.

Short answer

As of November 2026, .NET MAUI 11.0.0 GA is released; this manual connection recipe follows the current Microsoft networking guide. Android's 10.0.2.2 aliases host loopback (address map).

Diagnostic: Connection refused

Tanvirarjel's July 16, 2021 report records a connection-refused report; it does not establish a current runtime defect.

Choose / don't choose

  • HTTP: choose for disposable local debugging when encryption is unnecessary; permit only the intended development destination.
  • HTTPS: choose to exercise TLS-dependent behavior or protect sensitive development traffic. Trust a controlled development CA in the debug app (Android); host-side trust alone is insufficient (Microsoft).

Not for: physical-device automation; see android-phone-control-for-agents.

Settings that matter

Setting or flagValue / defaultApplies toSource
HttpClient.BaseAddressAbsolute URI; example http://10.0.2.2:5000/, substituting actual scheme/port, before any requestCurrent HttpClient docsproperty, MAUI
android:usesCleartextTrafficDebug-only true permits broad HTTP; default false for target API 28+; ignored when targeting API 38+Android manifest contractmanifest
android:networkSecurityConfig@xml/network_security_config; include XML as AndroidResourceCurrent MAUI Android docsMAUI
cleartextTrafficPermittedtrue in a domain-config whose domain is 10.0.2.2; keep allowance in debug buildsCurrent MAUI Android docsMAUI
debug-overrides / certificates srcTrust controlled CA resource, example @raw/debug_cas; active only with android:debuggable="true"Android debug HTTPSsecurity config

Order of operations

1. Start the API; confirm its real listening scheme/port on the host. For HTTP, select a launch profile that accepts HTTP rather than redirecting to an unconfigured HTTPS endpoint (MAUI). 2. Map host loopback to the emulator alias; inspect reachability from the emulator (address map). 3. Apply the matching Android cleartext or debug-CA policy, rebuild the debug app, then issue a request through HttpClient. On API 24+, network-security configuration takes precedence over the manifest cleartext flag (manifest). 4. Inspect the inner exception, endpoint and selected handler. Confirm release builds exclude development trust and HTTP exceptions.

Known failures and fixes

Error (short quote)CauseFixSource

| java.security.cert.CertPathValidatorException | Development chain is untrusted on Android | Configure debug trust; retain hostname validation rather than accepting every certificate | MAUI, Android | | Cleartext request refused (symptom) | Android transport policy disallows HTTP | Use scoped debug network-security exception or valid HTTPS | manifest |

Missing

  • API port, certificate names and selected MAUI HTTP handler are application-specific. The networking guide currently renders the MAUI 10 documentation view; no MAUI 11-specific handler change is asserted.
  • The linked source does not confirm: physical-phone endpoint requirements; a general listener/address diagnosis before TLS evaluation; the certificate hostname/IP validation rule.

Checked

2026-11-12; GA release, Microsoft networking/property references, Android address/manifest/security references and dated runtime report read. No API or emulator commands executed.

Started from a post by @Microsoft, packaged by the editor. Original post

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# .NET MAUI: reach a host API from Android emulators
Summary: Point the emulator at the host alias, then distinguish listener, cleartext-policy and certificate failures before changing transport settings with `HttpClient.BaseAddress`
Copy for agent
get the whatworks thread maui-android-emulator-host-api-transport-policy and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread maui-android-emulator-host-api-transport-policy
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks