HTTP Failure in Axios Error: Network Error(only on android)

See original GitHub issue

Description

I’m using Axios as my request library.

const client = axios.create({
  baseURL: 'https://my.domain.com/api/',
  responseType: 'json'
});

Once I request. This error comes in.

HTTP Failure in Axios Error: Network Error
    at createError (createError.js:16)
    at EventTarget.handleError (xhr.js:83)
    at EventTarget.dispatchEvent (event-target-shim.js:818)
    at EventTarget.setReadyState (XMLHttpRequest.js:575)
    at EventTarget.__didCompleteResponse (XMLHttpRequest.js:389)
    at XMLHttpRequest.js:502
    at RCTDeviceEventEmitter.emit (EventEmitter.js:189)
    at MessageQueue.__callFunction (MessageQueue.js:425)
    at MessageQueue.js:112
    at MessageQueue.__guard (MessageQueue.js:373)

But it works great on iOS, I did try some solutions, none of them worked for me. But it used to work well, I remembered I did not change anything. It happened suddenly.

React Native version:

System: OS: macOS 10.15.5 CPU: (4) x64 Intel® Core™ i5-7360U CPU @ 2.30GHz Memory: 21.28 MB / 8.00 GB Shell: 5.8 - /usr/local/bin/zsh Binaries: Node: 12.18.3 - /usr/local/bin/node Yarn: 1.21.1 - /usr/local/bin/yarn npm: 6.14.6 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.9.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2 Android SDK: API Levels: 23, 27, 28, 29 Build Tools: 28.0.3, 29.0.3 System Images: android-28 | Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 4.0 AI-193.6911.18.40.6514223 Xcode: 11.6/11E708 - /usr/bin/xcodebuild Languages: Java: 1.8.0_251 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.11.0 => 16.11.0 react-native: 0.62.2 => 0.62.2 npmGlobalPackages: react-native: Not Found

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

6reactions
Liqiankuncommented, Sep 3, 2020

emulator @<your_emulator_name> -dns-server 8.8.8.8 saved my day. For more info Android emulator: when there’s no connection to the internet @freddieerg Thanks, you give me the right clue.

1reaction
charbelsakocommented, Feb 22, 2021

my problem was that i used localhost when the emulator had to connect to my ip 10.0.2.2:5000

@Liqiankun Yes i did and that returned an error that -dns-server is not known as a command

Read more comments on GitHub >

github_iconTop Results From Across the Web

Axios post request network error on android · Issue #4823
So i'm posting a formdata object with axios to a node.js server. On iOS everything works perfectly, the data get posted and the...
Read more >
Network Error when use axios in React Native
Within my react native project(react-native-cli), I send request to server using axios package. But when I'm testing with my android phone, it ...
Read more >
React Native [AxiosError: Network Error] HTTP Fetching iOS ...
React Native cannot fetching using HTTP, so need HTTPS for ... React Native [ AxiosError : Network Error ] HTTP Fetching iOS and...
Read more >
How to Handle API Errors in Your Web App Using Axios
It can mean anything from “Your device doesn't have internet connectivity” to “Your OPTIONS returned a 5xx” (if you make CORS requests). The...
Read more >
Axios gives Network Error on android 6 : r/reactnative
So what's the problem? Use android 7 or above and use http with clear text traffic and https.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found