React Native on iOS: Network Request Failed

Written by Raymon Schouwenaar on

By default iOS isn’t supporting HTTP requests, only HTTPS requests are allowed.

But what if you have an API that only works with HTTP, you can easily change the setting’s to support HTTP requests.

When I first tried to do a request to an HTTP address it gave me the error “Network Request Failed”. I couldn’t get why.

But after some digging, I figured iOS was only supporting HTTPS.

To change this, open the “info.plist”. You can find this at ‘ios/ProjectName’.

Search for <key>NSAppTransportSecurity</key>. If it’s there already you only need to this code below it:

    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>

Now close your simulator and kill the running process (if you already started it). Run react-native run-ios again, and now your iOS app will support HTTP calls.

Hope this will help to fix your problem with React Native 🙂


Latest posts

What is the JavaScript Set in ES2015 and when should you use it?

The ES2015 spec is full of new features that continuously be introduced in all the new browsers. The Set collection is one of those new things.

My first thought was, well I could just use a normal Array! But I will show you what you can do with the Set collection.

CSS Grid Layout Metro design blocks

The times have come that we don’t have to fiddle around with Floats and Tables anymore! Flexbox is already an established term in the industry of Frontend Developers.