26

I have seen similar questions on Stackoverflow but none sorted the problem. I have just created new ReactNative project from Expo desktop app. But I can not run it on my Android phone via QR code scan when Expo configuration is set to LAN mode. Which seems not accessible on my Android phone (looks like). My phone is on same Wifi network.

I have also tried to run Expo demo app by turning off Firewalls but still no success. I'm sure your one technical look might soft my issue.

Note: The Expo tunnel was down that's why it loaded in LAN mode. Few days ago I tried Tunnel mode which works. But, at that time too LAN didn't work. So may be any one can point me in right direction, so I can run it in LAN mode (being on Phone and Machine on same Wifi Network).

My IP Config

Expo Desktop App

Expo App when tries to load demo app after scanning QR code

Netstat command result for port 19000

Nah
  • 1,690
  • 2
  • 26
  • 46
  • 1
    @mano did a great help, so +1 for it. But purposed solution did not resolved the problem related to Expo desktop tool. Problem still persist and did not resolve. However, Expo CLI tool resolved my problem and allowed me to setup a functional development environment. So, in reference to the other people having similar problem and looking for the solution; I am marking the Expo CLI as proposed solution for now (which is also recommended by Expo), till any one post a correct solution for Expo Desktop app. – Nah Dec 27 '17 at 12:01

14 Answers14

32

I am not sure this helps you or not but in my case, this helps me so you can also try this:

1: First of all you have to increase the WiFi Adapter priority( Interface Metric)

Goto Control Panel > Network and Internet > Network Connections

step 1) Right-click on the wi-fi as shown in the above image and right-click > Click Properties

steps 1 screenshot

step 2) select Internet Protocol Version 4 and > Click Properties

steps 2 screenshot

step 3) click on > Advanced

steps 3 screenshot

step 4)

  1. Uncheck 'Automatic Metric'
  2. Enter 5 in 'Interface Metric'
  3. click ok

steps 4 screenshot

2: You have to change your wifi network profile from Public to private

step 1) selecting your network from available WiFi network and click Properties

steps 2 screenshot

step 2) change your network profile from Public to Private

steps 2 screenshot

That's it now run your expo project on LAN it will work 100%

  • 1
    It works for me thanks you saved my lot of time, – arslan Feb 26 '21 at 07:56
  • Surprising alternative/addendum: NOTHING seemed to work for me until I nmapped my local network. I threw in several scripting options: `broadcast-dhcp-discover,broadcast-dhcp6-discover,dhcp-discover`. I previously tried setting static IP assignments too (which fixed the ARP on the laptop, but not the phone), but that did not change anything on the phone. It seems like this forced android to refresh ARP in some way. – Alexander Riccio Jul 12 '22 at 23:12
14

Your Android phone is unable to reach the server as the virtual adapter network is being used as the preferred subnet.

Increase the WiFi adapter priority and it should run fine. (Uncheck Automatic metric in Advanced Adapter settings and assign a lower number for interface metric).

See this link: Adapter priority setting unavailable in Windows 10

Mano
  • 314
  • 1
  • 5
  • I followed the instructions and changed Adapter priority as mentioned. Now it looks Expo desktop app is displaying correct local IP (in its settings address bar), hence now the Expo setting says: exp://192.168.100.7:19000 But if I try to load on my phone, it shows same error screen but with new server IP (192.168.100.7). Firewall is off on my machine. Anything else to see? I did restart my machine after changing adapter setting. – Nah Dec 25 '17 at 11:09
  • Try killing expo app on phone and retry again by scanning the QR-code. I think it should work. – Mano Dec 25 '17 at 13:02
  • I have killed Expo app in Android phone, tried to load using QR code again but in vain. I have tried closing the desktop App as well but no success. However when I ping (using a utility app) my local IP 192.168.100.7, it returns success on phone. Only the expo is not loading the app. In error log (in mobile) it says: `could not load exp://192.168.100.7:19000` Do I need to run any other command on a side along having Expo desktop app loaded the project running? But I don't think so, as I created project via Expo desktop app. – Nah Dec 25 '17 at 13:42
  • Are there any additional logs? Try running the basic app. Also upgrade both the XDE and Expo app to the latest one to avoid any mismatch issues. – Mano Dec 25 '17 at 13:47
  • I have tried Expo CLI tool, and it worked well. I'll wait for any appropriate solution which work for XDE desktop app, as it still does not assist to load app in Mobile. I feel there might be problem with QR code. I have posted my CLI solution though. – Nah Dec 25 '17 at 16:47
  • I'm not sure who has been such an intelligent stupid to down vote this answer, as this answer is really relevant and helped me to resolve the issue. If I would say that this answer is 50% correct and moved me close to resolve the problem (posted in the question) then I will not be wrong in any sense and is as per Stackoverflow rules. And I posted the question. So no one should down vote this answer. Thanks – Nah Aug 15 '18 at 02:19
  • this is true answer. – ozkanpakdil Mar 23 '19 at 10:45
13

After struggling through the XDE Desktop app but no success. Finally decided to try the Expo CLI tool as mentioned here: https://expo.io/learn With few simple steps, it created 1st demo project for me.

And by following CLI command here: https://docs.expo.io/versions/latest/guides/exp-cli.html I am now able to run my first demo app with simple command e.g. exp start --dev --lan, which does the same job that XDE (Expo Desktop) app does of configuring settings to LAN and in Developer Mode.

I had gone through every possible solution but non worked for me to setup LAN connectivity, except the Expo CLI tool. Any one facing similar problems? Please go and give CLI a try. But make sure you check your Network Adapter priority settings (as VMWare/VBox network adapter's priority does create problem). As proposed by @mano.

Nah
  • 1,690
  • 2
  • 26
  • 46
6

I had roughly this issue on my Ubuntu/Crouton setup and the problem there was that I had a local firewall blocking the port.

The fix there was to use iptables to open the port, like this:

$ sudo apt-get install iptables
$ sudo /sbin/iptables -I INPUT -p tcp --dport 19000 -j ACCEPT

More info here: https://github.com/dnschneid/crouton/wiki/Running-servers-in-crouton

I can imagine similar solutions might be needed on other platforms too.

Nemo
  • 2,441
  • 2
  • 29
  • 63
Rob Ennals
  • 61
  • 1
  • 1
6

On Windows 10:

  1. You should click on connection Properties:

connection Properties

  1. Then change the Networking Connection from Public to Private in Network Profile.

Networking Connection

Matheus Abreu
  • 3,357
  • 1
  • 18
  • 21
4

In Windows 10 I had the same problem. I did these tasks:

  1. Changed the priority of the network interfaces.

    How to change the priority order of network adapters on Windows 10

    Before:

    Image1

    After:

    Image2

    The mobile and the computer must be on the same network (check the mask). In my case, Virtual Box changed the priorities.

  2. I turned off the firewall and I check and saw that the app was working. Then I did the correct adjustments to the firewall.

1

FWIW, for me, I had set nodejs to "allow connections via private networks only", but my wifi network on my Windows machine was not set up as private. I changed it from public to private, restarted the app and then it worked fine.

Tur1ng
  • 745
  • 8
  • 22
0

On OS X, it turned out that the firewall was blocking my 19000 port. Going to

Setting > Security & Privacy

and Turning firewall off solved it.

itsmysterybox
  • 2,748
  • 3
  • 21
  • 26
Kirill Kovalevskiy
  • 1,942
  • 2
  • 11
  • 8
  • This solution proved that macOS firewall was blocking connections from the iPhone Expo app. I don't want to keep it off, though. Which specific app should I *"Allow incoming connections"*? – Ricardo Sep 18 '19 at 19:48
0

I had the same problem. You should turn off Firewall public or set inbound-outbound on the further.

Tai Lu
  • 43
  • 7
0

I was somehow able to identify the problem. You just need to do ipconfig /all (windows) or ifconfig (Unix) and check for Wireless LAN adapter WIFI IPV4 Address and replace the host in exp URL with it.

exp://192.168.84.161:19000 (This published URL on expo start was using ethernet IPV4 address instead of Wireless LanIPV4 192.168.0.10).

Changing the host and directly hitting it on safari opens an expo app and loads the react app successfully.

0

In my case, I had Docker desktop client installed on my PC. I just uninstalled Docker from my pc and it's working.

Sunny Sultan
  • 1,090
  • 15
  • 20
0

If you are Windows user, make sure your Antivirus Firewall has been disabled.

0

In my android it used to work but one day it stopped and started working after android reboot.

wings
  • 338
  • 4
  • 15
0

For me it only worked to disable all other network adapters.

My windows pc has multiple network interfaces and the LAN URL points to a different one than that the mobile device can connect to.

(Setting the REACT_NATIVE_PACKAGER_HOSTNAME environment variable or setting the priotities of the adapters did not work for me)

And of course I was on the private network and had disabled the firewall for it until I configured it.