ghost
ghost

Reputation: 59

Unable to resolve host: No address associated with hostname

In my Android application I use my Rest API, delivered via the cloudflare network (with active proxy). Very often the first connection to the okhttp API receives the following error:

Non-fatal Exception: java.net.UnknownHostException
Unable to resolve host "mydomain.com": No address associated with hostname

After the user retries one or more times, subsequent connections are successful. If there is some downtime with API requests, the error is likely to occur again.

I cannot understand what causes this problem. If it can depend on cloudflare or if there is a way to solve on the okhttp side.

do you have any ideas?

Upvotes: 4

Views: 26377

Answers (3)

AgentZee
AgentZee

Reputation: 17

I had the same problem with one of my crypto wallets only to discover my app needed to be updated and once I updated the app everything was smooth from that point on. When I first went to the Play Store to see if I had any updates due, there were none but when I searched specifically for my wallet app in the Play store an update was needed. So make sure you search for the specific app that is giving you the problem in the Play store.

Upvotes: 0

The Aamit
The Aamit

Reputation: 15

I have also the same issue but after restarting android studio it solved my problem.

Upvotes: -4

Narek Hayrapetyan
Narek Hayrapetyan

Reputation: 1929

Or you have no internet on the device

or you forgot to add

<uses-permission android:name="android.permission.INTERNET" />

permission in manifest.xml

@see this thread

Upvotes: 0

Related Questions