HTTP Post requests failing on android, works as expected on ionic serve

Hi There

I am having a bit of an issue with regards to HTTP requests from my mobile app, when testing with ionic serve the app works perfectly and successfully sends HTTP posts to the server and receives data,
however when running the app on android my HTTP posts fail with the following error -> Http failure response for ionic.

Read a few forum responses and added the following code below hoping it would remedy my situation.

I’ve added the following code to my config.xml

 <application android:usesCleartextTraffic="true" />

and (code below) in network_security_config.xml

<domain-config cleartextTrafficPermitted="true">
    <domain includeSubdomains="true">localhost</domain>
    <domain includeSubdomains="true">172.20.175.8/</domain>
</domain-config>

I still get the same issue, cannot connect to the server and make HTTP posts.

Please could someone kindly assist me

What’s the URL? If you’re trying to connect to localhost, when your app is running on an Android device then localhost means the Android device itself, not your laptop or workstation.

1 Like

Hi, I seem to have figured it out, i had a slash in the 172.20.175.8/, I’ve removed it and now it is working.

Thank you