Can't make requests to local API server
See original GitHub issueDescription
Can’t connect to an API server ran on my local machine from my android phone running my Expo app. The IP address of my machine on my local network is 192.168.1.14
, so my app is served on the URL http://192.168.1.14:19000
. My API server is on http://192.168.1.14:3000
, and I can connect to it on my phone browser.
Expected Behavior
The fetch request to http://192.168.1.14:3000
should return the same data as the request through my browser.
Observed Behavior
I have to wait around 30 seconds of awaiting for a response, then I get this:
Possible Unhandled Promise Rejection (id: 0):
TypeError: Network request failed
onerror@http://192.168.1.14:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&hot=false&minify=false:13802:29
dispatchEvent@http://192.168.1.14:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&hot=false&minify=false:14702:39
setReadyState@http://192.168.1.14:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&hot=false&minify=false:16809:31
__didCompleteResponse@http://192.168.1.14:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&hot=false&minify=false:16665:27
http://192.168.1.14:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&hot=false&minify=false:16760:50
emit@http://192.168.1.14:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&hot=false&minify=false:5278:40
__callFunction@http://192.168.1.14:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&hot=false&minify=false:3517:47
http://192.168.1.14:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&hot=false&minify=false:3375:29
__guard@http://192.168.1.14:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&hot=false&minify=false:3489:11
callFunctionReturnFlushedQueue@http://192.168.1.14:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&hot=false&minify=false:3374:19
callFunctionReturnFlushedQueue@[native code]
Environment
Please run these commands in the project folder and fill in their results:
npm ls react-native-scripts
: react-native-scripts@0.0.30npm ls react-native
: react-native@0.44.2npm ls expo
: expo@17.0.0node -v
: v7.4.0npm -v
: 4.0.5yarn --version
: 0.24.5watchman version
: 4.7.0
Also specify:
- Operating system: Ubuntu 16.04
- Phone/emulator/simulator & version: Android 6.0.1
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Can't make requests to local API server · Issue #241 - GitHub
You could try this: Open "Node.js command prompt" and type ipconfig . From there, copy your IPv4-IP-address. ... That worked for me.
Read more >Cannot connect to localhost API from Android app
You can not access a local api outside from that local device. 127.0.0.1 is the local address of its own. If you want...
Read more >Unable to Consume Rest API from Local Server - OutSystems
A rest API can only be consumed if it has a valid public domain or public IP address so that it can be...
Read more >Localhost api call not working - Just getting started - Postman
Hi, I am trying to interact to my back-end golang server which is running on port number 9000.I tried to connect by changing...
Read more >Unable to access HTTP based Web Api from HTTPS based ...
You can have a try the wildcard value "*" to see if it works. this will allow requests from any origins. 50251-image.png. Thanks...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hello! I think you may be mistaken and have made some error somewhere in your code. see https://github.com/brentvatne/crna-issue-241-example for a minimal example of what you describe in this issue, and notice that it works as expected. if that example doesn’t work for you then let me know!
you need to be able to access the server from your phone. if you can’t access it from a web browser you also can’t access it from an app