Cannot send HTTP request on Android, but I can on iPhone

  1. SDK Version: 36
  2. Platforms: Android

Hello -

I’ve been working with expo for some time now, but only using it to build iOS apps.

A current project has a working iOS app that can make requests to my local and production servers. I also have it deployed on iTunes where it works as intended.

I want to have this application on Android as well. The issue I am having is that I cannot make requests to the backend. The same actions working on iOS don’t make it to my server on Android.

The error I am receiving on the Android emulator is -

TypeError: Network request failed
    at XMLHttpRequest.xhr.onerror (fetch.umd.js:473)
    at XMLHttpRequest.dispatchEvent (event-target-shim.js:818)
    at XMLHttpRequest.setReadyState (XMLHttpRequest.js:574)
    at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:388)
    at XMLHttpRequest.js:501
    at RCTDeviceEventEmitter.emit (EventEmitter.js:189)
    at MessageQueue.__callFunction (MessageQueue.js:436)
    at MessageQueue.js:111
    at MessageQueue.__guard (MessageQueue.js:384)
    at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:110)

I am hoping I am missing something easy, and any help would be appreciated. I am currently using Android Studio for the emulator.

Bump, I’m having the same issue. Certificates on my Back End service are correct, nevertheless, I should be able to send traffic via http if I want. Is there anyone else that can enlighten us? (and don’t suggest ejecting please)

Hey I was able to fix this.

I needed to point my localhost url to 'http://10.0.2.2:8000'

10.0.2.2 is an alias to the loopback address of the host machine.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.