Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • 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!

like image 510
Nieck Avatar asked Apr 17 '26 07:04

Nieck


1 Answers

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.

like image 193
Nieck Avatar answered Apr 20 '26 00:04

Nieck