fetch [TypeError: Network request failed] on iOS 18.4
Description
fetch() was working on 18.2 and older but in the new 18.4 ios is not working it gives the error
[TypeError: Network request failed]
I ran the same code on both simulators and the desirable result didn't work as expected. It happened to me in specific apis like google maps, I tried wikipedia api, it worked! I tested with axios/fetch.
Steps to reproduce
just call google maps fetch(https://maps.googleapis.com/maps/api/place/autocomplete/json?sessiontoken=${sessionToken}&input=${text.replace(/\s+/g,"+")}&key=${this.API_KEY}&limit=10${t}&language=en) it works on ios 18.2 but fails on 18.4. it fails specifically for google maps but works to other endpoints.
React Native Version
0.76.9
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: macOS 15.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 483.07 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.4.1
path: ~/.nvm/versions/node/v22.4.1/bin/node
Yarn:
version: 1.22.21
path: /usr/local/bin/yarn
npm:
version: 10.8.1
path: ~/.nvm/versions/node/v22.4.1/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.14.3
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.4
- iOS 18.4
- macOS 15.4
- tvOS 18.4
- visionOS 2.4
- watchOS 11.4
Android SDK: Not Found
IDEs:
Android Studio: 2024.3 AI-243.24978.46.2431.13208083
Xcode:
version: 16.3/16E140
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.14
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: ^18.0.0
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.76.9
wanted: 0.76.9
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Stacktrace or Logs
[TypeError: Network request failed]
Reproducer
https://github.com/faustoct1/codes/blob/main/fetch-rn.js
Screenshots and Videos
No response
@faustoct1 Can you also try once on latest react-native version: 0.78.x and let us know.
Thanks
@devanshsaini11
Same error on ios 18.4:
- "react-native": "0.78.2",
- "axios": "^1.8.4",
Also experiencing this issue! I'm getting errors from expo-notifications and expo-file-system related to failed network requests on my iOS simulator and real device using iOS 18.4. I'm using react-native version 0.76.9. Unfortunately, I can't update to 0.78.x as I'm using many Expo libraries!
Running into this too with Expo using the react-native-auth0 library which calls fetch under the hood.
The only way i've found to "get around" this via the iOS simulator is to hit Device -> Erase all content and settings to wipe the state and app binary installation, then reinstall everything.
Restarting the app with Device -> Restart to load a new JS bundle will bring back the [TypeError: Network request failed] fetch error.
Looking into it more, requests are stuck in a pending status in the RN devtools.
And mention an issue with Network.streamResourceContent.
@faustoct1 Can you also try once on latest react-native version:
0.78.xand let us know. Thanks
Hi, I'm running in a deadline I can't upgrade it for now. I'll do it as soon as I get free time. If there's a patch I can try, since it's just run a command meanwhile I'm using rn+expo, it's quite painful to upgrade, and make sure everything is working fine ! I tested on my published app and it's working, it seems to be a problem on simulator.
Running into this too with Expo using the
react-native-auth0library which callsfetchunder the hood.The only way i've found to "get around" this via the iOS simulator is to hit
Device -> Erase all content and settingsto wipe the state and app binary installation, then reinstall everything.Restarting the app with
Device -> Restartto load a new JS bundle will bring back the[TypeError: Network request failed]fetch error.
I had the same problem with auth. I did exactly this and it worked! I tested on my published app and it's working on a real device, the problem only happened on simulator for me.
I reported this issue here since I faced it first before the fetch issue https://github.com/react-native-google-signin/google-signin/issues/1419
I can confirm that it works fine on an iOS 18.4 physical device, but there is an error when using the iOS 18.4 simulator.
I erased the 18.4 simulator, rebuilt and installed my app; it worked for about 5 minutes, and then the same problem returned. I went back to the 18.3 simulator, and all is good. Running React Native 0.77.2
I can confirm that it works fine on an iOS 18.4 physical device, but there is an error when using the iOS 18.4 simulator.
I erased the 18.4 simulator, rebuilt and installed my app; it worked for about 5 minutes, and then the same problem returned. I went back to the 18.3 simulator, and all is good. Running React Native 0.77.2
I kept iOS 18.4 due it's not happening on physical device. Those are the related issues I found on 18.4 ios simulator beside the fetch..
https://github.com/RevenueCat/purchases-ios/issues/4954 https://github.com/react-native-google-signin/google-signin/issues/1419
They can somehow be related, all of them seem to happen over the network.
Same for me. Was also able to reproduce it on physical ios devices
Steps to reproduce:
- Open app
- Set it to background mode (minimize it)
- Wait for 3-5 hours
- Open app again and attempt to make a network request
The request fails with a network error, despite the network being available (confirmed by successfully making a request using axios)
Error code:
Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."
UserInfo={
_kCFStreamErrorCodeKey=-4,
NSUnderlyingError=0x600000cf6a60 {
Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)"
UserInfo={
NSErrorPeerAddressKey=<REDACTED>,
_kCFStreamErrorCodeKey=-4,
_kCFStreamErrorDomainKey=4
}
},
_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E4C1DA73-E3D0-4950-A614-4C350ADFFF34>.<10>,
_NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <E4C1DA73-E3D0-4950-A614-4C350ADFFF34>.<10>"
),
NSLocalizedDescription=The network connection was lost.,
NSErrorFailingURLStringKey=https://<REDACTED>,
NSErrorFailingURLKey=https://<REDACTED>,
_kCFStreamErrorDomainKey=4
}
Additional Notes: • This issue only appears after the app is in the background for an extended period. • Other requests (e.g. via axios) work fine after resuming. • Might be related to iOS’s handling of backgrounded apps and stale network sessions. • Occurs consistently on React Native 0.74.x through 0.76.x (have not tested other versions yet).
Same problem for us. We have this in revenue cat (react-native-purchases) and firebase (react-native-firebase) also sometimes acts up.
This is an issue that affects iOS 18.4 simulators only. Check this thread for more info.
I had the same problem, but for a website running through Cloudflare - React Native app does requests to it. I temporarily disabled HTTP 3 there and everything worked. Not the best way, but there are too many problems with HTTP 3, as everyone has their own implementation of the protocol. I'll wait for a fix from Apple for 18.4 at least.
Rolling back to old xcode to use old simulators is much longer and will only hinder development if working on multiple projects.
I have the same issue. When I build the new app by uninstalling and reinstalling it, it works fine. However, after reloading, the network stops working.
Same here
same here using RN 0.76.9 and iOS 18.4.
Have same issue on 18.3 and 18.4 simulators and one real device (18.3). This issue appears periodically and resolves automatically.
On last week I faced with this issue on real device on application version from App Store
I have this issue on:
IOS simulator version 18.3
React Native: 0.74.1
Expo: "^51.0.5"
android emulator works fine.
Same issue here. I was also able to reproduce it on a real device and emulator. Axios requests work, but fetch does not. Everything works fine on Android, looks like only ios is affected
react-native: 0.76.9
expo: "^52.0.44
"expo": "^52.0.46", "react-native": "0.76.9"
Same here, it happens after a few refreshes. Tried with node 18, node 20.18 and node 20.19.
Safari wont open the page because the network connectin was lost.
This may be an IOS 18.4 simulator issue or Xcode 16.3 issue. Either way you cant install an older IOS simulator if you have Xcode 16 installed... I may wait for a fix or downgrade to Xcode 17.5
yes I had to downgrade Xcode to 16.2 and use a simulator with iOS 18.3
My observations on the problem:
Simulator: iOS 18.4 (Xcode 16.3, macOS 15.4)
url's:
- https://clients3.google.com/generate_204
- https://www.google.com/recaptcha/api.js
In the application, a network error occurs when executing the fetch function. There is no problem when opening the same link in Simulator's Safari browser.
Xcode 16.3 and iOS 18.3 sim is a working combo for me. As already pointed out, this is most likely an issue with 18.4 sim.
Came back to give my feedback and indeed I downgraded to IOS18.3 with Xcode 16.3 and the network error is gone. No need to downgrade Xcode, only the IOS for the simulator.
I use the iPhone 15 Pro with IOS 18.3 and Xcode 16.3 and no error so far.
The problem seems to be the IOS 18.4
same issue fixed by downgrading to iOS 18.3 on sim.
No need to downgrade Xcode folks, just download iOS Sim 18.3.1 using Xcode.
I can attest, this is a IOS 18.4 simulator issue, im also having issues with authentication using firebase and i just keep getting unknown network errors. Downgrading to 18.2 works fine. Need to test on real device but assuming itll be okay.
same
Hitting the same problems - network errors when app runs in Simulator with iOS 18.4. Occasionally network errors also affect Safari, but that is intermittent. Downgrade to 18.3 resolves the issue. Never saw the issue on real device with 18.4, but I only tested few times manually (contrary to Maestro testing in Simulator).
Any solution please. Other than downgrade!