Calling locally hosted APIs from Expo Apps

Mahdi Karimipour
3 min readMar 21, 2021

--

Debugging Mobile Apps (iOS, Android) Built using Expo

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.

Network Errors

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).

Pellerex Foundation: For Your Next Enterprise Software

How are you building your current software today? Build everything from scratch or use a foundation to save on development time, budget and resources? For an enterprise software MVP, which might take 8–12 months with a small team, you might indeed spend 6 months on your foundation. Things like Identity, Payment, Infrastructure, DevOps, etc. they all take time, while contributing not much to your actual product. These features are needed, but they are not your differentiators.

Pellerex does just that. It provides a foundation that save you a lot development time and effort at a fraction of the cost. It gives you source-included Identity, Payment, Infrastructure, and DevOps to build Web, Api and Mobile apps all-integrated and ready-to-go on day 1.

Check out Pellerex and talk to our team today to start building your next enterprise software fast.

--

--

No responses yet