-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[React Native] EXPO - AxiosError: Network Error on Android but not on IOS #24606
Comments
hi there! could you try to use some network inspector tool to get more information of the requests? https://docs.expo.dev/debugging/tools/#inspecting-network-traffic |
Hello! Our GitHub issues are reserved for bug reports. If you have a question about Expo or related tools, please post on our forums at https://forums.expo.dev/ or join our Discord at https://chat.expo.dev/. Resources |
will try to follow up your questions here and reopen it if it's confirmed as an issue. |
facing the same issue |
looks like the problem is related to this topic facebook/react-native#32931 (comment) |
I have an identical error. Does anyone have a solution for this? |
U right, replace "localhost" for the ip and work it |
I was a same issue. The request was success on IOS, but the Android throw Network Error without response. (In the server the request response status was 200 in both case) Sample code: const formData = new FormData()
formData.append("name","*********")
formData.append("country",{
id:1,
name: "*****"
})
return await instance.post('profile', formData, {
headers: {
'Content-Type': 'multipart/form-data',
accept: 'application/json',
},
}); The problem caused the county object field. |
facing the same issue, any solution ? |
In my case I just posted the countryID. |
Same problem here, on expo go with ios the request works, but in android dont. The worst thing, i have 2 urls to make a get requests and the URL's ares the SAME, and one works and the other no. This ulr works the get: And this ulr dont works: Is the same, just change de ID, like ???? |
If you guys want get the dev ip for develop, here are some useful snippets: import Constants from 'expo-constants';
const host = Constants.expoGoConfig?.debuggerHost?.split(':')?.[0];
const API_URL = process.env.EXPO_PUBLIC_API_URL || '';
export const baseURL =
host &&
(host.startsWith('192.168') || host.startsWith('10.') || host.startsWith('172.')) &&
(API_URL.indexOf('localhost') > -1 || API_URL.indexOf('127.0.0.1') > -1)
? 'http://' + host + ':' + (API_URL.split(':').pop() || '')
: API_URL; |
I am facing the same issue, if anyone here has the solution I am interested. |
Try replace "localhost" for the ip? @JorgeHabib |
same problem here, axios calls work on Expo Go but when I try from the .apk I get network error |
I am facing this issue when hitting directly the prod endpoint, not development. |
If you find any solutions for this, I am still facing this same issue. |
Please any solution for this? |
I had the same issue, I have a .net api running on my server and an apache server acting as a proxy. I added my lets encrypt certificate to the apache server. But I didn't add the certification chain file!!! When I added it, it worked. Android apparently requires the chain file for LetsEncrypt certificates. |
Minimal reproducible example
(https://snack.expo.dev/@mathissou/trusting-orange-hummus)
Summary
Description
**### Describe the bug **
On Android, with Axios my request is returning "AxiosError: Network Error".
But it all work fine on IOS and with POSTMAN too.
The api call uses HTTPS and is not local
### Solution tried:
I have tried many headers type but none works.
Also the ""usesCleartextTraffic": true" in "AndroidManifest.xml" and with "expo-build-properties" is not doing anything.
Downgrading axios at any version do not change anything.
The SSL respond good when I test them with some website SSL tester online.
All the TLS1, TLS2, TLS3 are working.
For me it looks like Android does not make the request correctly.
It does not work in Local and after the build too
Can you please explain to me what is wrong?
Thank you in advance.
### Code snippet of the API request:
### Additional Library Versions :
"dependencies":` { "@expo/config-plugins": "~7.2.2", "@react-native-async-storage/async-storage": "1.18.2", "@react-native-masked-view/masked-view": "0.2.9", "@react-navigation/bottom-tabs": "^6.5.8", "@react-navigation/native": "^6.1.7", "@react-navigation/native-stack": "^6.9.13", "@react-three/fiber": "^8.13.7", "@reduxjs/toolkit": "^1.9.5", "axios": "1.3.4", "babel-plugin-react-native-classname-to-dynamic-style": "^0.22.0", "babel-plugin-react-native-classname-to-style": "^1.2.2", "babel-plugin-react-native-platform-specific-extensions": "^1.1.1", "chroma-js": "^2.4.2", "expo": "~49.0.11", "expo-asset": "~8.10.1", "expo-checkbox": "~2.4.0", "expo-constants": "~14.4.2", "expo-device": "~5.4.0", "expo-exotic-asset": "^1.0.4", "expo-file-system": "~15.4.4", "expo-gl": "~13.0.1", "expo-linear-gradient": "~12.3.0", "expo-media-library": "~15.4.1", "expo-notifications": "~0.20.1", "expo-splash-screen": "~0.20.5", "expo-status-bar": "~1.6.0", "expo-system-ui": "~2.4.0", "expo-three": "^7.0.0", "lottie-react-native": "5.1.6", "metro-react-native-babel-transformer": "^0.77.0", "react": "18.2.0", "react-dom": "18.2.0", "react-native": "0.72.4", "react-native-animatable": "^1.3.3", "react-native-calendars": "^1.1300.0", "react-native-date-picker": "^4.3.3", "react-native-dropdown-picker": "^5.4.6", "react-native-extended-stylesheet": "^0.12.0", "react-native-form-component": "^2.6.12", "react-native-gesture-handler": "~2.12.0", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-reanimated": "~3.3.0", "react-native-safe-area-context": "4.6.3", "react-native-screens": "~3.22.0", "react-native-stylesheet-plus": "^0.3.0", "react-native-svg": "13.9.0", "react-native-view-shot": "3.7.0", "react-native-web": "~0.19.6", "react-redux": "^8.1.2", "three": "^0.145.0", "expo-build-properties": "~0.8.3" }
React Native Version
0.72.4
Output of
npx react-native info
System:
OS: Windows 10 10.0.19045
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 7.15 GB / 15.77 GB
Binaries:
Node:
version: 18.16.0
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.19
path: C:\Program Files\nodejs\yarn.CMD
npm:
version: 9.5.1
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowAllTrustedApps: Disabled
IDEs:
Android Studio: Not Found
Visual Studio: Not Found
Languages:
Java: Not Found
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.4
wanted: 0.72.4
react-native-windows: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Steps to reproduce
none
Snack, screenshot, or link to a repository
none
Environment
expo-env-info 1.0.5 environment info:
System:
OS: Linux 5.4 Ubuntu 20.04.6 LTS (Focal Fossa)
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.1/bin/yarn
npm: 8.15.0 - ~/.nvm/versions/node/v16.17.1/bin/npm
npmPackages:
expo: ~49.0.11 => 49.0.11
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.72.4 => 0.72.4
react-native-web: ~0.19.6 => 0.19.8
Expo Workflow: managed
The text was updated successfully, but these errors were encountered: