Nieck
Nieck

Reputation: 1646

React native expo - Reponse timed out

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:

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!

Upvotes: 2

Views: 6660

Answers (5)

Kim T
Kim T

Reputation: 6416

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

{
  "manifestPort": 8000
}

Upvotes: 0

Haider
Haider

Reputation: 41

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

Upvotes: -1

Shiju S S
Shiju S S

Reputation: 51

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

Upvotes: 0

Brit Mansell
Brit Mansell

Reputation: 786

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.

Upvotes: 5

Nieck
Nieck

Reputation: 1646

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.

Upvotes: 5

Related Questions