Unhandled Exception: SocketException: Failed host lookup: (OS Error: No address associated with hostname, errno = 7)

Question:

we already have a release version in playstore and its working just fine.
But suddenly now when we try to build and run the code again since we want to add new functionality. It would no longer communicate with our backend.

So i searched the net using the error as keyword and saw that need INTERNET PERMISSION as the 100% result and answer, which we have already and not helpful at all. Yes we have it in debug and live manifests.

The server is up we can access it in the browser and as well as postman also dig command
Using DIG

So i searched more things in the net to no avail, found about the because proxy issue thing i tried both client side and server-side. we don’t have proxy

Client Side

Server Side

we use simple request only like this:

also some suggestion say to use DIO, but i want to know the reason first before i gave up with this http plugin. Can someone with good heart explain and help me with this?

P.S. we on master channel, here are some error logs
enter image description here

Answer:

The error SocketException: Failed host lookup: 'api.xyz.com' (OS Error: No address associated with hostname, errno = 7) usually means that your DNS lookup fails. From the error itself OS Error, is usually a system-level error and nothing specific to http or Dart/Flutter.

You might need to adjust some settings in your DNS. Also, if you are using a Mac/Linux system you might be able to run dig api.xyz.com to see if that resolves.

Running your app in the actual device could be possible as well since there is a possibility its getting an error in your virtual device due to DNS settings or the virtual device you are using is not connected to the internet. You will be able to isolate the problem.

Leave a Reply