fetch fails with [TypeError: Network request failed] on Android with certain url
See original GitHub issueReproduced on React-Native 0.21, 0.22.0 , and 0.22.2
fetch('https://api-dev.semios.com/', {
method: 'POST',
}).then((response) => {console.log(response)}).catch((error) => {console.log(error)})
fails with [TypeError: Network request failed] only on Android – this works properly on iOS Reproduced with https://rnplay.org/apps/MUs3SQ
I/ReactNativeJS( 2790): [TypeError: Network request failed]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:16 (5 by maintainers)
Top Results From Across the Web
HTTP Fetch fails with "TypeError: Network request ... - GitHub
There are 83 issues opened and unanswered about network requests failing with this generic error. The main causes of the pain are: Not...
Read more >Fetch() returns "TypeError: Network request failed" for specific ...
As for the error you're getting, TypeError: Network request failed from within an Android app -- it's very possible that your Anrdoid app...
Read more >Improve "TypeError: Network request failed" error message
I get error messages when I make a request with fetch api on android (btw the same code is working perfectly fine on...
Read more >How to solve 'TypeError: Network request failed' in React ...
two thing : 1. add android :usesCleartextTraffic="true" in your Android manifest android /app/src/main/AndroidManifest.xml2.
Read more >[typeerror: network request failed] - You.com | The AI Search ...
Since your Android device has an IP of its own, you need to point the URL to your computers IP address instead of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m having a similar issue but mine isn’t even related to SSL. I’m just trying to run the example
fetch
from the RN docs calling out to http://facebook.github.io/react-native/movies.json. When I try it out on the simulator its fine. But when I plug in my device and and deploy it to that usingreact-native run-android
it can’t seem to successfully load the data.Any suggestions?
Adding in my case here: Similar situation as OP, https URL failing with
[TypeError: Network request failed]
on Android, successful on iOS, certificate showing as valid in browser.In my case, had SSL setup on nginx with Let’s Encrypt but left out the intermediate certificates, i.e. I was using the
cert.pem
instead offullchain.pem
. This thread has some more info. Once I got the intermediate cert configured correctly, Android/OkHttp accepted it.