Navigate back to the homepage

Network request failed in react native fetch

Infinitbility
React Native, SSL
March 15th, 2021 · 1 min read
Network request failed in react native fetch

Hello Friends 👋,

Welcome To Infinitbility! ❤️

Getting error TypeError Network request failed in android, ios, or with SSL server then read all below cases.

In this article, we solve 3 cases of network request failed issue in react-native but your condition does not match with the below mention cases then comment below on the article.

Case 1: http url not working in android

if you are trying to call HTTP ( unsecured ) url then you have to add usesCleartextTraffic to your AndroidManifest.xml.

AndroidManifest.xml

1<application
2 ...
3 android:usesCleartextTraffic="true" <!-- add this line -->
4 >
5 ...
6</application>

Trying to call localhost api with diffrent port?

Replace localhost with your ipaddress v4

To know your ipv4

  • For windows users
1ipconfig
  • For Mac or linux users
1ifconfig

HTTP URL not working in ios

If you are trying to call an unsecure url from reac native ios.

you have to do below changes on your info.plist to allow unsecure url

1<key>NSAppTransportSecurity</key>
2<dict>
3 <key>NSAllowsArbitraryLoads</key>
4 <true/>
5</dict>

HTTPS URL not working in android react native fetch

You are trying to call HTTP URL from react-native fetch but getting Network request failed to issue or in ios working fine then below the solution for you only.

This has to do with Android not trusting my SSL certificate. Apparently Android has some additional trust requirements on top of what web browsers require.

After figuring that out, the root cause ended up being my SSL Certificate uploaded to AWS didn’t have the correct intermediate cert which was fine in chrome, but not in android.

check your SSL certificate set up perfectly or not on https://www.digicert.com/help/.

when you get an error on DigiCert assign a task to your server administrator 😁.

Thanks for reading…

More From React Native Tutorial

Basics

1. Introduction To React Native

2. React Native Environment Setup using expo

3. React Native Environment Setup for windows

4. React Native Environment setup on Mac OS

5. React Native Environment setup on linux

6. React Native Project Structure

7. React Native State

8. React Native Props

9. React Native Styling

10. React Native Flexbox

11. React Native Text

12. React Native Textinput

13. React Native Commands

14. React Native ScrollView

Advances

1. React Native Dark Mode

2. React Native Fonts

3. React Native SQLite

4. React Native DatepickerAndroid

5. React native ScrollView scroll to position

6. How to align icon with text in react native

7. React Native Image

8. React Native Firebase Crashlytics

9. React Native Async Storage

10. React Native Share

Error & Issue Solution

1. Task :app:transformDexArchiveWithDexMergerForDebug FAILED In React Native

2. Expiring Daemon because JVM heap space is exhausted In React Native

3. Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED In React Native

4. Unable to determine the current character, it is not a string, number, array, or object in react native

5. App crashed immediately after install react native video or track player

6. how to delete SQLite database in android react native

7. React native material dropdown twice click issue

8. How to get the current route in react-navigation?

9. how to disable drawer on the drawer navigation screen?

10. Image not showing in ios 14 react native

11. React Native image picker launchimagelibrary on second time issue

12. how to open any link from react native render Html

13. Network request failed in react native fetch

14. React Native upload video example

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

how to open any link from react native render Html

how to open any link from react native render Html

react native render html link click issue

February 26th, 2021 · 1 min read
React Native image picker launchimagelibrary on second time issue

React Native image picker launchimagelibrary on second time issue

React Native image picker launchimagelibrary doesn't open image gallery when click second time.

February 22nd, 2021 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]