Fix cleartext HTTP traffic not permitted in Android

There is an error when you try to connect to a HTTP server.

Cannot send data to the server CLEARTEXT communication to [HOST] not permitted by network security policy

Starting from Android 8, there is a special security policy which requires connection via HTTPS protocol instead of HTTP. So, if you use HTTP, the system shows the error.

There are 2 methods to address this issue.

One is to use HTTPS instead HTTP. Nowadays, most online services is secured behind SSL so it is normal to use HTTPS.

The other method is to add an exception to the security policy.


Set android:usesCleartextTraffic to true allows HTTP connection.

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.