Closed techyrajeev closed 6 years ago
The errors Failed host lookup: 'api.xyz.com'
and OS Error: No address associated with hostname
usually mean that your DNS lookup fails.
As hinted by OS Error
this is usually a system-level error and nothing specific to http
or Dart.
To diagnose this on your system you can try check e.g. your browser can DNS resolve the host in question. And/or if you're on a Mac/Linux system you might be able to run dig api.xyz.com
to see if that resolves.
When doing anything network, or I/O in general, it's a good idea to program very defensively and assume the I/O can sporadically fail or time out. You can try see if you can make your code degrade more gracefully in cases when e.g. DNS isn't working as expected.
I'll go ahead and close this issue since I don't think there's anything to be done in http
Anyone facing this issue: try adding <uses-permission android:name="android.permission.INTERNET" />
to your AndroidManifest.xml.
thank you, this worked for me
I had the same error. In my case it was because the emulator of the phone that I am using does not have access to the internet.
Run the application on a physical mobile device and it worked immediately.
Solution connect the emulator to the internet.
I think we need to add message that you need to add internet permission in Install section of doc
I think we need to add message that you need to add internet permission in Install section of doc
Please +1 and follow https://github.com/flutter/flutter/issues/29688
If we have some flutter docs to point to from this README we can do that.
I have the same issue when run in release mode,but it is ok when debug mode !
@Derkin - please raise the issue at flutter/flutter#29688
This isn't a problem that can be solved in this package.
Hi, This error is because if your Simulator or Your phone doesn't connect to the Internet.
Anyone facing this issue: try adding
<uses-permission android:name="android.permission.INTERNET" />
to your AndroidManifest.xml.
@gurgenDP pls help me this way dont solve my problem flutter/flutter/#43357
Just ran into this issue. After about half an hour I finally figured out that it was because I had my VPN on..
I have the same issue when run in release mode,but it is ok when debug mode !
i have same issue with my app . So have u figured it out now???
@jawale204 - please raise the issue at flutter/flutter#29688
This isn't a problem that can be solved in this package.
I have the same issue when run in release mode,but it is ok when debug mode !
i have same issue with my app . So have u figured it out now???
This error is because if your Simulator or Your phone doesn't connect to the Internet.
I made new minor sdk updates, upgraded the http package, closed the emulator and re-opened it, and stopped the application and re-compiled the problem was fixed.
The errors
Failed host lookup: 'api.xyz.com'
andOS Error: No address associated with hostname
usually mean that your DNS lookup fails. As hinted byOS Error
this is usually a system-level error and nothing specific tohttp
or Dart.To diagnose this on your system you can try check e.g. your browser can DNS resolve the host in question. And/or if you're on a Mac/Linux system you might be able to run
dig api.xyz.com
to see if that resolves.When doing anything network, or I/O in general, it's a good idea to program very defensively and assume the I/O can sporadically fail or time out. You can try see if you can make your code degrade more gracefully in cases when e.g. DNS isn't working as expected.
I'll go ahead and close this issue since I don't think there's anything to be done in
http
that was valuable insight, thanks @cskau-g man. I was worried about this issue. It was DNS, I was messing with my DNS settings.
people kept spamming about the missing Internet Permission. That wasn't my case. It was hard to find this info. I'll set the DNS to default settings and see if it's resolved.
thanks again! 👍🤝
I had the same error. In my case it was because the emulator of the phone that I am using does not have access to the internet.
Run the application on a physical mobile device and it worked immediately.
Solution connect the emulator to the internet.
This solved the issue for me. Thanks a lot!
@jawale204 - please raise the issue at flutter/flutter#29688
This isn't a problem that can be solved in this package.
step 1 add
to you androidmanifest, if done, step 2 connect your emulator to a internet, if you cant use in on your physical device
Anyone facing this issue: try adding
<uses-permission android:name="android.permission.INTERNET" />
to your AndroidManifest.xml.
HAVE TRIED THE ABOVE BUT THE SAME ERROR EXISTS PLS HELP....
I am also facing the same error after doing all the steps mentioned above. Please suggest.
Failed Host Lookup error occurs when their is no internet connection in the AVD in the laptop...... Suggestion is to close the AVD, check your internet connection and then open your AVD and then run again......
Also if their is a problem in the API itself the. This error might occur..........
That's how I did solve it...
Just restart the emulator that's it
On Tue, Dec 15, 2020, 8:15 AM AYAN BHATTACHARYA notifications@github.com wrote:
That's how I did solve it...
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dart-lang/http/issues/185#issuecomment-745015911, or unsubscribe https://github.com/notifications/unsubscribe-auth/AODLGO5DP76Y5W2BSK5ROPTSU3EWBANCNFSM4FLL2Q5Q .
I had this issue and the cause of this error for me was that my phone was not connected to the internet 🤦♂️
I've faced this issue after trying to build my flutter apk for the first time, with the intention to test it on a real android device.
After building, the issue occurred on both devices (real and emulator).
<uses-permission android:name="android.permission.INTERNET" />
. What helped was reinstalling the http package.
Just ran into this issue. After about half an hour I finally figured out that it was because I had my VPN on..
Thanks you are my hero! same issue hehe
my problem was with the api url it was inccorect.
In my real android device, it is NOT working with Jio internet. With airtel and other networks, it's working fine. Do telecom operators put proxy etc. in the http requests?
In my real android device, it is NOT working with Jio internet. With airtel and other networks, it's working fine. Do telecom operators put proxy etc. in the http requests?
For our app users using Jio network this issue happens some times. On same device it works some time, and does not work some time. Server has ipv4-only ip. Only A record is set on DNS server.
In my real android device, it is NOT working with Jio internet. With airtel and other networks, it's working fine. Do telecom operators put proxy etc. in the http requests?
For our app users using Jio network this issue happens some times. On same device it works some time, and does not work some time. Server has ipv4-only ip. Only A record is set on DNS server.
I solved it by changing api url. Jio uses some SNI url filtering mechanism.
So for some reason my previous api endpoint was not being hit.
Hi, yes its correct, thank you This error is because if your Simulator or Your phone doesn't connect to the Internet.
Just ran into this issue. After about half an hour I finally figured out that it was because I had my VPN on..
Yes. I have same problem. When i turn VPN ON i have failed host lookup, but internet is working in browser. My requests is not, how can i fix it? I really need work with VPN
i tried every thing , nothing work !!
We receive this error when running our app for a specific internet provider. We tried hitting same API for same network provider by native android app , it worked fine. but with flutter it did not work. App works fine when we use VPN. Without VPN we are receiving this error. anyone can suggest anything.. that would be great help... Thanks
In my real android device, it is NOT working with Jio internet. With airtel and other networks, it's working fine. Do telecom operators put proxy etc. in the http requests?
For our app users using Jio network this issue happens some times. On same device it works some time, and does not work some time. Server has ipv4-only ip. Only A record is set on DNS server.
I solved it by changing api url. Jio uses some SNI url filtering mechanism.
So for some reason my previous api endpoint was not being hit.
Can you tell me what exactly you did. Because I am facing same issue
In my real android device, it is NOT working with Jio internet. With airtel and other networks, it's working fine. Do telecom operators put proxy etc. in the http requests?
For our app users using Jio network this issue happens some times. On same device it works some time, and does not work some time. Server has ipv4-only ip. Only A record is set on DNS server.
What is solution then ?
Getting this error while calling api.
Sometimes I receive response occasionally. I tested the api using postman it is working perfectly fine. Version: http: ^0.11.3+16
[ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception: E/flutter (24807): SocketException: Failed host lookup: 'api.xyz.com' (OS Error: No address associated with hostname, errno = 7) E/flutter (24807): #0 IOClient.send (package:http/src/io_client.dart:30:23) E/flutter (24807): <asynchronous suspension> E/flutter (24807): #1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:171:38) E/flutter (24807): <asynchronous suspension> E/flutter (24807): #2 BaseClient.post (package:http/src/base_client.dart:56:5) E/flutter (24807): #3 post.<anonymous closure> (package:http/http.dart:70:34) E/flutter (24807): #4 _withClient (package:http/http.dart:167:20) E/flutter (24807): <asynchronous suspension> E/flutter (24807): #5 post (package:http/http.dart:70:3) E/flutter (24807): #6 NetworkUtil.post (package:ddictor/utils/network_util.dart:29:10) E/flutter (24807): #7 loginUser (package:ddictor/utils/api.dart:23:16)
post method inside network_util file
` Future post(String url, {Map headers, body, encoding}) {
return http
.post(url, body: body, headers, encoding: encoding)
.then((http.Response response) {
final String res = response.body;
final int statusCode = response.statusCode;
}