React Native: Network request failed FIX

React Native Network request failed

In this post we will fix the Network request failed error in iOS simulator that is common for many React Native new-comers.

NOTE: this article is related to environment issue, but request may also fail because of badly configured ajax call.

A lot of people that dives into React Native get stuck when trying to make a simple HTTP GET-request. And there can be much more than one reason for that but let’s look to the most common mistake that causes the failure of network request.

react-native network request failed stacktrace

Fixing ‘Network request failed’ error

First of all, when you try to use the network in your app, you should enable it in XCode.

  1. Click on your project in the Project Navigator
  2. Open the Info tab
  3. Right click on App Transport Security Settings and select Add Row
  4. For created row set the key “Allow Arbitrary Loads“, type to boolean and value to YES.

react-native enable networking

After that rebuild your project and the network request should pass successfully.

Leave a Reply

3 Comments on "React Native: Network request failed FIX"


Guest
Jim
9 months 27 days ago

Just so others know, you can just open the fetchExample/ios/fetchExample/Info.plist file in Xcode and do as you say above. To me it wasn’t clear since I was just using the react-native cli to build and run.

Thank you for posting this!

Guest
Theo
10 months 22 days ago

Thank you, thank you, thank you! I’ve been stuck on this for an entire day – all the other posts that offer the same solution only show the xml in the info.plist – nobody showed step-by-step how to edit the file in XCode – I was editing it in a text editor to no avail. Problem fixed! Thank you!