Can't connect my Android Phone in Expo React Native Project

Viewed 16381

I'm using Expo App in my Android Device to connect into the my Laptop's Expo (Signed in both my same Expo's Account)I am also connected in the same network. Then I scanned my code then after that it is unable to connect it. This is the error:

Uncaught Error:java.net.ConnectException: Failed to connect to localhost/178.0.0.1:190000

There is also an eror that I get in my Expo's Laptop:

enter image description here

Sometimes the URL is not the same. It should be same, right? How do I solve this. Thank you in advance!

9 Answers

First off make sure to turn off all of your anti-virus software including anything that has firewall protection. You have to do this on both your computer and your phone. It can be kind of a pain in the butt

Then try using the "Tunnel" connection for the type of connection. I had the same problem and that's how I finally got it to work on my phone.

If you're using Windows, make sure the network you are using is configured as a Private network. If it's set as a Public network, you will not be able to connect.

Steps I followed that solved my issue

  1. Restarted Router.
  2. Clear Expo Go data from settings
  3. Run expo start and everything working good now

In my case the problem was in my phone, which didn't connect to same wifi, but instead used mobile internet. To check it you use modem mode on your phone and connect your computer by wifi to it. In this case you can be sure both devices connected via same net, and I hope it may solve the problem.

I solved this issue by connecting the physical phone(That you are using to connect with the App) hotspot with the laptop instead of another Wifi.

sometimes shift+r is working. it clears cache

For those who are using physical android device via cable, try to activate USB tethering on android and set the expo connection to local. It works for me. Hope it help someone in the future.

To solve this issue follow these steps:

  1. Update your expo cli by command npm install -g expo-cli
  2. Turn on your hotspot from mobile and connect it to your desktop or laptop.
  3. make sure the network is set to be private otherwise you will not be able to access the application.
  4. Login in expo from mobil as well as laptop from same account.
  5. now scan or manually tye the url in expo app and that will rendrer your app.

I had this problem with the newest expo-cli version (6.0.1), which does not seem to have the "tunnel" option anymore. The funny thing is that the device sometimes connects, but frequently not.

I downgraded to v5.5.1, and could connect again using the tunnel option.

Related