Liza Catherine Ombyaw
Liza Catherine Ombyaw

Reputation: 904

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

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!

Upvotes: 21

Views: 44967

Answers (22)

achille
achille

Reputation: 661

Restarting my (linux) computer made the connection work again.

Hopefully saving someone else a few minutes with this unsatisfying yet classic answer.

Upvotes: 0

Kibiku Brian
Kibiku Brian

Reputation: 441

First install expo npm i expo then run npx expo start --tunnel

Upvotes: 0

Jyothilakshmi c
Jyothilakshmi c

Reputation: 235

Try to connect it with your mobile network as it is private network, Or try after change your wifi access to private. This will work for me. And once change your network please restart the server for get new connection.

Upvotes: 1

totallytotallyamazing
totallytotallyamazing

Reputation: 2923

I upgraded my Expo SKD from 46 to 47 and my Android Expo Go, testing dev environment now works.

From my local project terminal, (MacOS Monterey, using VS Code) I ran this:

yarn add expo@^47.0.6

As of Expo Go Client version 2.29.1, Only SDKs 47, 48, 49 are supported.

-- Be sure to only upgrade Expo SKD Client versions one at a time, (DO NOT Skip versions, e.g. go from say 46 to 48).

Sourced: Upgrade Expo SDK -- (Link to Blog post for version 47 upgrade, recommends upgrading expo-cli with npm but since version 46 expo-cli was incorporated into expo and no longer installed globally but locally, I went with the above yarn add/update which worked like a charm.)

enter image description here

Upvotes: 0

Santosh Pandey
Santosh Pandey

Reputation: 27

I don't why these answers are too complicated, I have very easy solution for this.

Try running your computer and mobile on same WI-FI network.

After executing the App.

just use EXPO app and try entering URL manually ..

URL should be exp://your_systems_IPv4_address:your_port

your_systems_IPv4_address : it can be in the format 192.168.0.1

port: it can be 19000 or 19001....

Thanks

Upvotes: 0

Shelton
Shelton

Reputation: 51

i uninstalled expo on my phone and rebuilt android. it worked

Upvotes: 1

lorihori
lorihori

Reputation: 11

npx expo start --tunnel                                              

In my case, solved with option --tunnel

https://docs.expo.dev/more/expo-cli/#server-url

Upvotes: 0

Abizer Susnerwala
Abizer Susnerwala

Reputation: 71

  1. If you are using a cellular network and connecting your laptop
    through the same mobile hotspot, ensure your connection is set to
    public on your laptop.
  2. If your laptop and mobile are connected to wi-fi, the connection must be private.

Upvotes: 2

Bamisile Tolulope
Bamisile Tolulope

Reputation: 1

tunnel is still your best bet if you ask me. i just fixed this same error using tunnel. and how to do it is very simple. go to your package json and where you have expo start add --tunnel to it, so it would look some thing like this: "script" : { "start" : "expo start --tunnel" } that would surely fix your issue, you can then use expo start -- tunnel or npm start, whichever you prefer

Upvotes: -1

I was using a previous link like 172.something but now on my new network the expo link was like 192.something, so realizing changed networks and using correct link helped me.

Upvotes: 0

Aquairo
Aquairo

Reputation: 51

environment variable doesn't work for me, npx expo start --tunnel is useful

Upvotes: 5

Ozer Ozturk
Ozer Ozturk

Reputation: 209

If you're using WSL(Windows Subsystem for Linux) like me and trying to run expo go via QRcode you generated in WSL; give it a try the same process in your Windows PowerShell. I applied the same steps and it worked this time.

Upvotes: 0

Ehtisamul H
Ehtisamul H

Reputation: 9

I solved my issue by deleting the eas.json file. Now expo app is working fine.

Upvotes: -3

RdC1965
RdC1965

Reputation: 582

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.

Upvotes: 0

Kousik Roy
Kousik Roy

Reputation: 1

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.

Upvotes: 0

Tosca
Tosca

Reputation: 453

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.

Upvotes: 2

Ruslan Valeev
Ruslan Valeev

Reputation: 1907

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.

Upvotes: 3

kaber
kaber

Reputation: 101

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.

Upvotes: 10

haidar
haidar

Reputation: 1789

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

Upvotes: 3

rufai demir
rufai demir

Reputation: 536

sometimes shift+r is working. it clears cache

Upvotes: 0

Niharika Sharma
Niharika Sharma

Reputation: 1

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.

Upvotes: 0

Peter Cr
Peter Cr

Reputation: 481

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.

Upvotes: 36

Related Questions