When connecting an iOS or Android app built using Expo to your data endpoints hosted on your localhost, you might hit a couple of roadblocks in terms of connectivity.

SAME Wi-Fi

Talking about the obvious, you need to make sure you are connected to the same Wi-Fi on both the device and your machine, so that 192.168… means the same thing.

No “localhost”

If you are using “localhost” in your URLs, that could be confusing for your device. Use exact IPv4 Address instead (something like 192.168.0.3, and not 127.0.0.1 or localhost). You can get that by running ipconfig and get your machines IP.
You should also make sure your API can be called using that IP address, and it is not bound to “localhost” when you hosted it on your machine.

Ports Open?

You also need to check that the ports hosting your APIs are open on your machine to accept traffic from your device with your network, which otherwise would lead to timeout error (“TIMEOUT_ERROR”) on your device. How To Open Firewall Ports In Windows 10 | Tom’s Hardware

Invalid SSL?

Also if in your code you are using https, and your SSL is not set up properly, you will also get the same vague “Network Error” when trying to call the API. In this case you should fix the local SSL problem on your machine, or go back to http (FOR LOCAL TESTING ONLY, THIS SHOULD NOT BE USED FOR HIGHER ENVIRONMENTS).

Closing Note

Feel free to check our scaffolds btw. As far as the code is concerned, we have sorted out many of these issues. You will be up and running on day 1 and can focus on your business functions instead of foundations. Using our Identity, Payment, and Scaffolds will accelerate your delivery speed by months.

  1. React Web App (technologyleads.io)
  2. .Net 5.0 API Scaffold (technologyleads.io)
  3. React Native Mobile Scaffolds are on the way!

Leave a Reply

%d bloggers like this: