Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

Can not connect to localhost api using React Native app run on real device iOS

$
0
0

I have been developing a React Native with a rails API running on localhost:3000. I have one endpoint only because I am using graphQL with Apollo Client, so I connect to the api with http://localhost:3000/graphql.

I am now trying to run the app on my own iPhone - connected via lightning cable. The app loads correctly but I am getting [Network error]: Network request failed. So having researched all I could, I changed localhost to my computer's IP address, so the endpoint I am trying is now http://192.168.20.75:3000/graphql. However I am still getting the same error.

Xcode output is also showing NSErrorFailingURLStringKey=http://192.168.20.75:3000/graphql.

The IP address is correct, as that's what I see in system preferences network section and also I can see that when React Native is loading the JS, it tells me it's "Loading from 192.168.20.75:8081". When I ran ifconfig I also see inet 192.168.20.75 netmask 0xffffff00 broadcast 192.168.20.255. I also tried 192.168.20.255 FWIW and no luck.

A different React Native app I worked on a couple of years ago worked when I had did this so I am really stumped trying to work out why this isn't working. Any suggestions would be much appreciated!


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>