Error [TypeError: Network request failed]
Description
I'm having this error right now, everything worked fine, but i don't understand why i'm facing this error, I've tried many solutions fot two days that's why i'm opening this issue solutions that i've tried changing url to my machine ip address added paermission on AndroidManifest added dns 8.8.8.8 to my network pereferences created new simulator tried on physical device
const handleSubmit = ({ question }) => {
let headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
};
let data = JSON.stringify({
question: question,
});
let options = {
method: 'POST',
headers: headers,
data: data,
};
fetch('http://10.0.2.2:8081/answer/', options)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log('error', error));
};
Version
0.68.2
Output of npx react-native info
System: OS: macOS 12.4 CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz Memory: 993.57 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.0.0 - /usr/local/bin/node Yarn: Not Found npm: 8.6.0 - /usr/local/bin/npm Watchman: 2022.03.21.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: API Levels: 28, 29, 30, 31 Build Tools: 29.0.0, 29.0.1, 29.0.2, 29.0.3, 30.0.0, 30.0.1, 30.0.2, 30.0.3, 31.0.0, 32.0.0 System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-30 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom_64, android-31 | Intel x86 Atom_64, android-31 | Google APIs Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7784292 Xcode: 13.4/13F17a - /usr/bin/xcodebuild Languages: Java: 18.0.1 - /usr/local/opt/openjdk/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.68.2 => 0.68.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
expo init i'm facing this error with a private project which was working but also when inilializing a new expo or react native projects
Snack, code example, screenshot, or link to a repository

fixed TypeError: Network request failed when upload file to http not https with Android debug builds
Hey I'm having the same issue. I also tried
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
and configured the XML and nothing works. This only started to happen when I upgraded my react native from 0.68 to 69.5. In ios all works fine.
using react-native-debugger solved the issue for me. but still having it without it
fixed
TypeError: Network request failedwhen upload file to http not https with Android debug builds
I have same issue. still need a solution
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.