React Native: Dev Server IP iOS vs Android

805 Views Asked by At

I'm running a DEV server locally on my Mac and want the mobile simulator to connect to it. After trying a few different things, I realized that iOS works fine when connecting to my server @ http://localhost:8080/api but Android requires my IP Address like http://192.168.1.105:8080/api. Is there a way to make localhost work on Android as well?

1

There are 1 best solutions below

0
On BEST ANSWER

In Android the localhost refers to the device on which the code is running, in this case the emulator.

If you want to refer to the computer which is running the Android simulator, use the IP address 10.0.2.2 instead. You can read more from here.