2

I'm trying to run an app inside my Android emulator and on my Iphone using Expo and Create React Native App.

I' ve ran the following commands to do this.

create-react-native-app MyFirstApp

npm run android

After doing the run command the app runs in the emulator with the following error:

Something went wrong! Could not load *ip*. Network response timed out.

Uncaught error: java.net.SocketTimeoutException: connect timed out.

The same thing happens when I scan the QR code on my Iphone and I can't reach the ip in my web browser.

I've found the following fixes on internet but nothing seems to work:

  • Add port 19000 to the inbound rules in Windows Firewall
  • Update Java and npm
  • npm start instead of npm run android

Edit:

I installed Expo XDE to start the server. It works fine when I use a tunnel but that option is extremely slow when reloading changes. It still doesn't work with localhost or LAN. Is it possible that I have to use something like port forwarding to open this port on my router?

Also: When I typ: localhost:19000 in Google Chrome I get some Json returned. But this doesn't work when I'm in Expo!

Nieck
  • 1,626
  • 3
  • 21
  • 41

5 Answers5

5

Fixed the problem! I just found the following solution:

Go to cmd and type ipconfig

get the ip4 adress of the virtual machine and copy it.

Than go to computer > properties > advanced system settings > environment variables and add the following system variable: REACT_NATIVE_PACKAGER_HOSTNAME

As the value for the variable I had to paste the ip4 of the virtual machine.

Nieck
  • 1,626
  • 3
  • 21
  • 41
  • I have similar kind of problem (with may a slight difference), but the solution doesn't work for me. I have posted details at: https://stackoverflow.com/questions/47966887/expo-lan-configuration-doesnt-work-for-new-reactnative-project – Nah Dec 25 '17 at 08:32
5

I had the same problem. My issue was that VirtualBox had installed a couple of virtual ethernet adapters and NPM was choosing one of those. After disabling those in Control Panel > All Control Panel Items > Network Connections, the Expo app connected as expected.

Brit Mansell
  • 786
  • 7
  • 7
0

Windows firewall blocks the request. You can define two inbound rules for Port 19000 and 19001

Shiju S S
  • 51
  • 1
  • 9
0

You can configure the port by defining a .exprc file containing:

{
  "manifestPort": 8000
}
Kim T
  • 5,770
  • 1
  • 52
  • 79
-1

I had same issue. I disable all other network adapter and left WIFI adapter enable. secondly you can also change the priority of adapter it also gonna work

Haider
  • 41
  • 9