Saturday, December 30, 2023

Why Expo Go app fails to connect with the Expo app server running on Windows?

Expo is a framework build around react-native framework to provide better developer experience and tools when building a cross-platform react-native application. The framework comes with the handy app called Expo Go, which can be used to test your application on your android or iphone device without the need to build any native packages out of your application.

Workflow to open the app on the physical device is simple, as you just have to follow these steps

  1. Install the Expo Go app on your android or iOS device
  2. Run the development server of your app using the command npx expo start
  3. Open the development server url from the Expo Go app (by scanning the QR code or manually)
However in Windows, even though the development server is running, Expo Go app might failed to load the app with following error
Uncaught Error: java.net.SocketTimeoutException: failed to connect to after 10000ms

It could be due to one of the following reasons.

Device and windows are in the different network

Connect both windows and the device which has Expo Go app to the same network. If both are in different networks then Expo Go app will not be able to find the development server running on Windows.

E.g. both the device and Windows will be in the same network if it is connected to the same router.

Inbound connection for the development server port is not allowed in Firewall

Open the Windows firewall as an administrator > select Inbound rules > select New rule > Choose port > Next > Select Specific local port and pass the development server port as value > Allow the connection > Choose all domain > Provide a name > and finish.

Port number of the development server will be printed along with the npx expo start command output.

Inbound connection to the node.exe application is not allowed in Firewall

If adding an inbound rule for development port still does not work, then it could be because the access for node.exe is blocked from firewall inbound rule.
Open the Windows firewall > select Inbound rules.

Search for any rule that blocks the access for node.exe and delete that rule, with that Expo Go app should be able to load the app from the development server.

No comments:

Post a Comment