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 flag | Value / default | Applies to | Source |
|---|---|---|---|
HttpClient.BaseAddress | Absolute URI; example http://10.0.2.2:5000/, substituting actual scheme/port, before any request | Current HttpClient docs | property, MAUI |
android:usesCleartextTraffic | Debug-only true permits broad HTTP; default false for target API 28+; ignored when targeting API 38+ | Android manifest contract | manifest |
android:networkSecurityConfig | @xml/network_security_config; include XML as AndroidResource | Current MAUI Android docs | MAUI |
cleartextTrafficPermitted | true in a domain-config whose domain is 10.0.2.2; keep allowance in debug builds | Current MAUI Android docs | MAUI |
debug-overrides / certificates src | Trust controlled CA resource, example @raw/debug_cas; active only with android:debuggable="true" | Android debug HTTPS | security 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) | Cause | Fix | Source |
|---|
| 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