# Flutter (Android): java.io.IOException: Cleartext HTTP traffic to api.example.com not permitted

**Code:** `Cleartext HTTP traffic not permitted` · **Category:** Flutter / Dart · **Seen on:** Flutter, Android

Android 9+ blocks plain `http://` requests by default; the app must use HTTPS or explicitly allow cleartext for that host.

## Meaning

Network security config prohibits cleartext since API 28. Prefer switching the API to HTTPS. For development servers, add a `network_security_config.xml` allowing cleartext for specific domains, or `android:usesCleartextTraffic="true"` for debug only.

## Common causes

- Calling an http:// URL on Android 9+
- Local dev server over HTTP
- Redirect from HTTPS to HTTP
- WebView loading http content
- Release build using debug-only manifest

## Quick fix

1. Use HTTPS endpoints
2. For dev add `android:usesCleartextTraffic="true"` in a debug manifest or a domain-specific config
3. Never allow cleartext globally in release

## Detailed fix by platform

### Android

1. `android/app/src/debug/AndroidManifest.xml`: `<application android:usesCleartextTraffic="true" tools:replace="android:usesCleartextTraffic"/>`

## How to diagnose

1. **URL** — http or https?
2. **Build** — Debug only?
3. **Host** — Specific domain config?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/flutter/cleartext-http-not-permitted)
