-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React-Native fetch, Network request failed. On android #10404
Comments
@Clcll please show the options of your fetch |
My requests using
And I get the following exception on browser:
Code:
Packages:
EDIT: |
@woniesong92 did you set Allow Arbitrary Loads = YES in info.plist? |
@sudhirvkumar I was thinking @woniesong92 's issue is running in IOS and now I think I might be wrong. |
Running into the same issue with Android using axios & fetch. |
Hey, I think we really don't have enough information here to debug this problem. Stack Overflow might be better for this, that way someone else can help edit the question. I'm going to close this issue, I'd try Stack Overflow if I were you. |
Actually I fixed my problem, I just used the IP address Port of my server that host my API. |
Guys, I encountered this issue as well. What I know so far is that |
Hi guys, I also get this issue randomly with the app installed on my iOS device. As this thread has been closed, is there a topic where we can find help ? |
@rcabral90 Could you detail your solution a bit? I'm using IP Address and port for the server that hosts my API, but it gives me the EDIT: I'm using http, not https |
I had the same issue on iOS, it is okie for first 4-5 requests but the error occur then, please suggest ! |
The thing is, that iOS is running in a simulator and Android is running in an emulator. |
Same problem with a public facing webhost. Network request failed. On Android btw. Edit: It seems different times between server and host caused this. |
Also running on this issue now with devices running on Android version 4.. using React Native version 0.40.0 |
I am facing same problem on react native android emulator. Is there a fix or solution. Please reply. |
How to replace localhost with IP address of my machine. |
I am also facing that |
Use 10.0.2.2 for default AVD and 10.0.3.2 for Genymotion |
+1 how can I fix it? Edit @rderwin way I fix it. Thanks |
I replaced fetch('http://localhost:3000/api/meetups') with the IP adress of my computer and it worked |
use your ip address in place of localhost,It should work |
@achakra21 @montrealks still it not working |
I was also facing the issue and i replaced the localhost with my ip address and it worked. |
@StephanPartzsch - You solved my problem. Thanks a lot. All credit goes to StephanPartzsch. Respect for you. |
@StephanPartzsch I just replaced localhost with my ip address. It is working fine. |
Nothing is working for me... |
@monolithed I think that error is telling you exactly what's wrong. You are giving an |
@aprilmintacpineda, nope. let body = new FormData();
body.append('image', {
uri: image,
name: 'image',
type: 'image/jpeg', // This is important for Android!!
});
await fetch(url, { body }); |
@monolithed Did you managed to solve it yet? where is that code located in the cycle of your software? |
@aprilmintacpineda, the problem has already been solved. That exception has occurred due to I forgot to pass the type field (required on Android) |
how woniesong92 says... Solution for me was instead of using localhost:port for the API address, actually using an IP address of the server. |
@vibhor-pandey i had the same problem and i fixed it by chaning server ssl to a paid ssl , by the way I changed ssl and now we have grade A+ and it fixed my problem; |
@AmirTahani some updates (including SSL) solved my problem 😄 |
I dont know how far this approach is good, but for me if I go to Then re-run the reac-native run-android, it seems to fetch the results perfectly without any network errors. |
@monolithed tnx mate! You have saved my day! |
in Android i have a problem same too. let url = "https://www.domain.com"; // real domain not localhost
` Package.json { "react": "16.0.0", "react-native": "0.50.0", } Error: TypeError: Network request failed |
@akiramouto there is no any exact statement about this error.
|
Please check if you can access google.com in the simulator. |
Sounds like a problem with certificate. https://stackoverflow.com/questions/48198757/cant-fetch-api-resource I tested some sites with this tool https://www.digicert.com/help/ And the websites that have the error: SSL Certificate is not trusted, are the ones that cause the error, TypeError: Network request failed |
In my case I had to specify the dns-server when starting up, which allowed me internet access. The following on Mac:
Will give you a list of emulators, then you will need to start one up with the DNS specified, e.g.
Also, in my config I was referring to a hostname that was configured in my /etc/hosts which seems to work for iOS emulator, but I have to go with the ip address on the android one. |
# this worked for me |
For iOS you'd still need to change it the actual local ip. In development mode for iOS React Native gets started on the device with reloading working through the local ip, so the app already has it. Maybe we could get access to it somehow in JS so we can avoid having to do it manually. |
I'm using iOS simulator from XCode, Android emulator from Android Studio. on Android it's |
@Clcll |
@Wowgreat there are multiple reasons as to why HTTPS would fail, it could be with certificates. I've tested Android and iOS on HTTPS and both worked well, in fact, iOS does not allow HTTP instead it will force you to use HTTPS. |
@aprilmintacpineda |
I'm working with React native and Flask REST API, i had the same issue. host= '0.0.0.0' Example: if __name__ == '__main__': app.run(debug=True, host= '0.0.0.0') Thanks to @jhadjar |
Just replace the link's https with http |
Hello, everything working fine on IOS but it's faild on Android
fetch('http://somesite.com/app/connect', { ........
Thank you before hand
The text was updated successfully, but these errors were encountered: