I've got virtual box installed. And when I look at the host > LAN > ip address is exp://192.168.56.1:19000.
How can I change it without disable the network? because it's my virtualbox ip and my device can't connect to it.
Thanks
You can specify the REACT_NATIVE_PACKAGER_HOSTNAME
environment variable to use the correct IP address.
If you're using XDE, then make sure to launch it from your project directory with xde .
after you've installed the command line tools.
set REACT_NATIVE_PACKAGER_HOSTNAME='192.168.1.2'
but on my expo still showing 192.168.56.1 ip address. already tried restart the expo project.
export env REACT_NATIVE_PACKAGER_HOSTNAME=192.168.2.108
and got the desired result of having the expo on this ip after npm start
.
set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.0.105
$env:REACT_NATIVE_PACKAGER_HOSTNAME = "10.1.1.175"
REACT_NATIVE_PACKAGER_HOSTNAME
with ip
, and re open cmd(power shell).
In windows you can use:
set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.59
set
is only used for one session. If you always wanna use the same ip after reboot you can use:
setx /M REACT_NATIVE_PACKAGER_HOSTNAME 192.168.1.59
Even after you set the custom ip, you still cannot connect the virtual box.
You need to set a port forward for the virtual mechine at networking setting page.
Just use the real host mechine ip for the app Expo.
REACT_NATIVE_PACKAGER_HOSTNAME='real host mechine ip' npm start
check your pc whether install virtualbox , disable VirtualBox Host-Only Network
go to win pc: Control Panel\Network and Internet\Network Connections
run again command expo start is ok
On the Windows Subsystem for Linux (Ubuntu 18.04.1 LTS "Bionic"), I had to use the export
command:
export REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.76
.
Open CMD
from your Project Directory and Run Command as set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.0.12
. Replace the ip with your own LAN ip address.
The Command set
is used to set the Environment variable locally, without defining it into Environment Variables.
I have similar kind of problem (with may a slight difference), but the solution doesn't work for me. Finally I tried Expo CLI tool which worked great for me and is also recommended by Expo team.
My detailed question (may help someone to resolve similar problem):
Expo LAN configuration doesn't work for New ReactNative Project
If you have "ubuntu in windows" configured you can automate the process and run:
for /F "usebackq delims=" %A in (`ipconfig ^| grep -A4 'Wireless LAN adapter WiFi' ^| tail -1 ^| awk '{print $NF}'`) do set REACT_NATIVE_PACKAGER_HOSTNAME=%A
My problem solved by reinstall expo client on ios simulator.
I was used expo v37 before but got this problem on v38, the problem was expo client not have expo sdk 38.
Sharing my experience using EXPO with Cloud 9 and AWS Amplify. Similar with you, the QR code gives exp://localhost:19000
As the Security Group has been configured to provide public access, I regenerate the QR code to have it accessible from public IP address of exp://X.X.X.X:19000, this can be scanned from IOS devices to EXPO.
REACT_NATIVE_PACKAGER_HOSTNAME environment variable is ment for react DevTools. For EXPO, you have to set EXPO_DEVTOOLS_LISTEN_ADDRESS environment variable. Here is the weird function that determines the hostname :
function devtoolsGraphQLHost() {
if (process.env.EXPO_DEVTOOLS_LISTEN_ADDRESS && process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {
return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();
}
else if (process.env.EXPO_DEVTOOLS_LISTEN_ADDRESS) {
return process.env.EXPO_DEVTOOLS_LISTEN_ADDRESS;
}
return 'localhost';
}
If you're still having this problem, try switching to tunnel connection. It'll install @expo/ngrok@ and then you can scan the qRcode. Its what I did and the connection worked without having to change the IP address
click 'npm start', open the browser where your application is running, and on the bottom left corner, you will find the QR code.
Above the QR code, three options are displayed saying 'Connection: Tunnel | LAN | Local'
which is defaulted to 'LAN'
. Just change it to 'Local'
.
Your application will be up and running.
For me, something completely different worked under Windows. My pc has multiple network interfaces and the LAN URL points to a different one than that the mobile device can connect to.
This was quickly solved by deactivating all unnecessary network adapters.
(Setting the REACT_NATIVE_PACKAGER_HOSTNAME environment variable 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.
Alternatively, to avoid having to deactivate a network adapter, you can also adjust the metrics or priority of the adapters like this:
if the above solutions don't work for you, remove the .expo directory and try again.