React Native Expo change default LAN IP - react-native

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.

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

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

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.

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:
goto Control Panel > Network and Internet > Network Connections
right click the desired connection (Higher Priority Connection)
click Properties > Internet Protocol Version 4
click Properties > Advanced
Uncheck 'Automatic Metric
enter 10 in 'Interface Metric
Click OK

Related

VS code can't ssh to server: failed to create hard link

SETUP
I have a windows 10 PC connecting to my linux server (ubuntu 18.04.2). I run/edit code on my powerful server by remotely accessing the server through VS code's ssh ability. It is super convenient to edit my code on the server with VS code...
THE ISSUE
Visual Studio code won't connect to my Linux server. What is weird is that I am able to ssh into the server from the terminal within VScode by just literally typing ssh <username>#<server-hostname>
However, when I do the Remote-SSH option within VScode then it does not want to connect to the server...strange...
Here is how I remotely SSH into server with VScode built in functionality (marked with red rectangle). Also part of this screenshot is my config file, which I have triple checked as correct (IP address and .ssh/id_rsa_gpu_1_solarpv_ssh location)
HERE IS THE ERROR OUTPUT
MY ATTEMPTS
I have made sure that the config file is setup correctly and that the IP address is correct.
I have ensured that the server's IP address is also in the 'known_hosts' file located at /Users/.ssh/
I even generated my own private key for SSH connection as advised by the great documentation here: https://code.visualstudio.com/docs/remote/troubleshooting#_quick-start-using-ssh-keys
Still getting the error of failed to create hard link...
With all of my back-end stuff done right, I am absolutely clueless regarding why this is an issue.
After spending literally 9 hours on this issue...here is the answer:
When you launch VScode and remotely access the linux server, the linux server is instructed to download and install a vscode server so that you (on the other side) can remotely connect to the server.
If the server does not have internet just make sure the following setting is ticked
This allows the remote server (without or with internet connection) to get the vscode server running.
To eliminate the "failed to create hard link error" go to the directory mentioned by the error, which in this case on linux server is
navigate to /home/<username>/.vscode-server/bin/0ba0ca.../
then remove/delete the hardlink file and target file which also has
the same name as the directory.
Then just attempt to remotely access your server again through
vscode and all should be fine
Here is also a discussion regarding the issue...if you still have problems https://github.com/microsoft/vscode-remote-release/issues/2507
I solved this by enabling the option Lockfiles in Tmp:
i just deleted the whole library and it works, i don't see anything wrong with doing that.
rm -r /path_to_project/.vscode-server/
if i'm wrong feel free to correct me :)
Try this
Just in case others need to try the same here is the detail
ctrl-shift-p and choose:
Remote-SSH: kill VS Code Server on Host...
Chose the host name
Selected the platform type (linux)
https://github.com/microsoft/vscode-remote-release/issues/4307#issuecomment-762882247
worked for me.

Network Response Time Out Error (create-react-native-app) (expo)

I am trying to run create-react-native-app on expo app in android.
Firstly ,I created the project by writing command
create-react-native-app test
then I executed
npm start
then scanned the qr code from expo app.
But after scanning QR code , I am getting following error:
Uncaught Error: Java.net,sockettimeoutException: failed to connect to after 10000ms
Github Issue:
https://github.com/react-community/create-react-native-app/issues/144#issuecomment-296631692
This is due to not open port from your machine.
Linux (Ubuntu)
In Ubuntu Run In terminal
sudo ufw status verbose
To view open port if you cannot found 19000 port open then you need to open port using
sudo ufw allow 19000/tcp
and then again run
sudo ufw allow 19001/tcp
to serve http for react native i solve this problem in my ubuntu using this method. I hope this will help you.
Windows
To open a port in the Windows firewall for TCP access
On the Start menu, click Run, type WF.msc, and then click OK.
In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane.
In the Rule Type dialog box, select Port, and then click Next.
In the Protocol and Ports dialog box, select TCP. Select Specific local ports, and then type the port number of the instance of the React port, such as 19000 for the default instance. Click Next.
In the Action dialog box, select Allow the connection, and then click Next.
In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect to the Database Engine, and then click Next.
In the Name dialog box, type a name and description for this rule, and then click Finish.
Similarly you can open port 19001 too.
Change connection from LAN to tunnel.
In my case the firewall settings alone didn't do it. My issue was that VirtualBox network devices were taking priority and the Expo host was starting on the wrong network.
On windows you can run ipconfig and look at the network adapters you have. npm/yarn start seems to take whatever shows up first in that list.
I found out about this from here: https://github.com/react-community/create-react-native-app/issues/60
If you don't need the other network adapters in the list, you can disable them in the Network Connections interface of the Control Panel.
If you need to use those connections and have Expo work then to solve the issue I followed this process:
Goto Control Panel > Network and Internet > Network Connections
Right click the desired connection (Higher Priority Connection)
Click Properties > Internet Protocol Version 4
Click Properties > Advanced
Uncheck 'Automatic Metric'
Enter 10 in 'Interface Metric'
Click OK
Repeat for the Lower Priority Connection, but this time put 20 into the 'Interface Metric'
You'll now use the higher priority connection as a default.
You can get around that by fixing your laptop's ip address to a static ip, let's say 192.168.1.69, then you need to change the react native packager ip address to the same of your laptop, using
set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.69 (Windows)
REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.69 (Mac & Linux)
start your project again and you're good to go.
I had done everything mentioned in context.
Just Changed my connected WiFi network from public to private.
This Worked for me
First of all, disable the unused network connection. In my case it was VirtualBox. Maybe it's using the same port. I am not sure about that. after disabling the unused connections then restart the packager. if you used npm then type
npm start
Found ipv4 address
open expo app then tap to explore button from bottom
write exp://[ipv4adress]:19000 to searchbar
Then your app will open
I suggest you install expo application for react native, link to official guide here
npm install -g exp
Then you can use Genymotion software to emulate different environment setting for your app an run:
exp start
If you use in the terminal "npm start" with native react, the following is for you.
I found out that if my application runs successfully IpV addresses of my computer, that are shown in the terminal and that is on Expo app are identical, for example:
ipconfig -> IPv4 Address. . . . . . . . . . . : 10.0.0.124
exp://10.0.0.124:19000
Based on this observation I solved this issue by the following way:
Close npm prompt script which is running app
Close Expo app
Find your IP by running command in the terminal:
ipconfig
Run command in NodeJS command prompt with your IP (for example 10.0.0.124)
set REACT_NATIVE_PACKAGER_HOSTNAME=10.0.0.124
Start Expo app, scan barcode
npm start
If it does not help, then use next steps recommended by React developers in addition to other reasonable efforts:
Install Genymotion with VirtualBox
SignUp at Genymotion site
Run Genymotion software and !!!SignIn
If you are using git bash for development then this solution by Icruz4 will help
Instead of
set REACT_NATIVE_PACKAGER_HOSTNAME
Use:
export REACT_NATIVE_PACKAGER_HOSTNAME='192.168.1.123'
Note:
When you run
npm start
Expo tells you in the output the IP it's using. If that IP is not the IP you want then the
REACT_NATIVE_PACKAGER_HOSTNAME
environment variable is not set properly
in Windows
run the ipconfig in command prompt
get the ip4 address and copy it.
Than go to
This PC > properties > advanced system settings > environment variables
add the following system variable: REACT_NATIVE_PACKAGER_HOSTNAME
As the value for the variable I had to paste the ip4.
then run the npm start
It's work for me
I've had the same issue. The problem is that the command yarn start or npm start finds the first enabled network adapter it finds which just happens to be the adapter for VirtualBox on my (and many other machines). The solution is to either:
manually set REACT_NATIVE_PACKAGER_HOSTNAME environment variable, or
disable the unused network adapter in Windows' Network Connection (see image)
The problem is that Expo finds the first Network adapter, and not the active network adapter that provides the internet connection.
change LAN to Tunnel to solve this issue
In case someone is still looking for the answer. Do the basic thing first, Disable the VirtualBox Host-Only Network first by opening your network configs. This worked for me.
If you have tried everything the other answers suggest and it still does not work, please also check that your computer and your phone are connected to the same WIFI network. For me this is what wasted an hour.
This issue could possibly be resolved by:
Setting your environment variable with alternative instructions here
Or
Assigning interface matrix priority for your network adapters with detailed instructions here or here.
Or
An Ubuntu machine is unable to open a port
After you make any changes, please restart the computer before testing if it works.
Good luck!
I tried many solutions, only this way helped me to solve this problem:
In Windows:
go to "Network and Connections" in Control Panel of windows (Network and Sharing Center>Change Adapter Setting)
Disable all virtual boxes which you can see here
Restart npm or yarn or expo...
In my case, this problem occurred because Expo android app need "draw over other apps" permission and I didn't give it. So I give this permission to Expo app and the problem solved..
One of the simplest and 100% working solutions is:
Enable the Mobile Hotspot of your development machine( PC or Desktop ) and connect your Android device with this hotspot.
Goto Control Panel > Network and Internet > Network Connections
You will land in here as shown:Network Connections setting
Then set the IP address of Local Area Connection(Your DESKTOP HOTSPOT) to a desired one, say: 192.168.1.69 by right-clicking on the concerned connection and then clicking on properties -> Internet Protocol Version 4(TCP/IPv4) -> Properties. Then set the priority of this connection to be the highest and this is best described here
Then open a command terminal and run:
set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.69 (Windows)
REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.69 (Mac & Linux)
Then restart your expo server by running npm start in your expo project folder and run the app on your Android device by scanning the generated QR code with the expo app.
This error beaus your port it is not open
just check port is open or not for ubuntu you can check using the following way
sudo ufw status verbose
check 19000 port open then you need it
then run following command if port not open
sudo ufw allow 19000/tcp
for other port runs following command
sudo ufw allow 19001/tcp
because http port not you are getting erro. above step solve your problem
similar for mac and windows check firewall setting once
Solution 1:- Connect both(your PC and mobile)with same network then scan the QR with expo application.
Solution 2:-Select / change connection type as Tunnel mention in local host development window of your browser then scan the QR with expo application.
I think this will help :)
I had the same issue I got this when I cancel the permission window of node js I solved it by going at the directory
On the Start menu, click Run, type WF.msc, and then click OK.
In the Windows Firewall and Advanced Security, in the left panel in Inbound Rules I had two options or rules disabled Node.js Serverside Javascript.
I simply double click and in new window In action, I select allow the connection and save
I had the same issue but after some research, I found that this is because your computer has previously connected to multiple adapters. Expo may pick the IP address of one of these. To avoid this
Go to the command prompt and write 'ipconfig'.
Copy the IPv4 Address under Wireless LAN adapter Wi-Fi.
Then wrte the below command.
set REACT_NATIVE_PACKAGER_HOSTNAME=(Your IP here)
i just want to remember this for those who only try to scan the QR Code
You need to connect your phone to your computer using a USB cable the first time you want to launch the app,that will install the app on your device then the expo scan will work, i think all the solution above will work maybe it's just because you didn't connect them first that everything didn't work
just read the docs
https://reactnative.dev/docs/running-on-device
I got it by using this command on my ubuntu system:
sudo ufw allow 19000/tcp
and then type this:
sudo ufw allow 19001/tcp
restart vscode and the expo server and then you are good to go!
For Linux Ubuntu 21.10
This is for users, that don't use UFW.
Make sure ufw is inactive, else, execute 'sudo ufw allow 19000'
sudo ufw status
List rules:
sudo iptables -L
This will output on clean Ubuntu like this:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Now allow port 19000 with command:
sudo iptables -A INPUT -p tcp --dport 19000 -j ACCEPT
Make sure that rule added:
sudo iptables -L
Expected output:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:19000
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
After restart all rules will be wiped, so we need to install package, that will add rules from a file rules.v4 on each OS boot
sudo apt install iptables-persistent
su root
iptables-save > /etc/iptables/rules.v4
Enjoy! :)
If you are on Mac OS, this fixed it for me:
System Preferences > Network > Wifi
Uncheck "Limit IP Address Tracking".
This might have to do with iCloud Private Relay blocking your Mac from being seen by other devices.
In Windows,
set REACT_NATIVE_PACKAGER_HOSTNAME=my-ip-address
worked inside my git bash terminal, but not cmd. In git bash, after I ran npm start, I got a firewall popup, which I clicked allow and it worked!
In your device: Log in to your expo app, create account if you doesn't have any.
In you system: open terminal go to you project directory via cd command and then type sudo exp start
it will ask you your expo account login details once you done with this.
It will gives you qr code to scan.
You Just need to open the port in Window Firewall and everything should work.
1.On the Start menu, click Run, type WF.msc, and then click OK.
In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane.
In the Rule Type dialog box, select Port, and then click Next.
In the Protocol and Ports dialog box, select TCP. Select Specific local ports, and then type the port number of the instance of the React port, such as 19000 for the default instance. Click Next.
In the Action dialog box, select Allow the connection, and then click Next.
In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect to the Database Engine, and then click Next.
In the Name dialog box, type a name and description for this rule, and then click Finish.
Similarly you can open port 19001 too.
If you have tried everything, and still not working for you. Change the Connection to 'Local' instead of 'LAN', it is working perfectly for me. It is not the best solution but does the work.

Conemu with x-forwarding

I currently am using Cmder (which is effectively conemu) to SSH into a university cluster from my Windows machine. I want to enable x-forwarding, and I have Xming installed. I followed the instructions here, which I swear I've used before but doesn't seem to work right now. Specifically, I type
DISPLAY=localhost:0.0;export DISPLAY;
once I open up a Cmder terminal (with Xming already loaded), but the error I get back is
Error: cannot open display: localhost:0.0
despite Xming saying it is Xming server:0.0. Any suggestions? I should add that the x-forwarding works perfectly fine with MobaXterm, but I'd prefer to stick with Cmder.
The issue was that I was setting the display variable on the client server, not the host computer. On my Windows machine, I opened Xming and then did
set DISPLAY=127.0.0.1:0.
Afterwards, I SSH'd into the client server via
ssh -X myname#address.
Now everything works as intended.
I have exactly the same problem. However, I have observed that if I open up a Putty session with x11 forwarding set, then add the display number to my ConEmu session that is ssh'd into the Linux box, then x11 works from ConEmu. Weird.
It is an inconvenient workaround at best.
I made it work for me.
Even so Xming was telling me "localhost:0.0", after connecting to the my server (using the "-x" ssh's option) I rather did :
DISPLAY=:10.0;export DISPLAY;
The following worked for me:
export DISPLAY=127.0.0.1:0
ssh -XC <hostname>

Microsoft Edge cannot reach VM with private IP

I have a webserver running in an VM (VirtualBox, configured with vagrant) which is assigned the private ip 10.0.0.20. I can reach the webserver with Google Chrome, but not with Microsoft Edge. I have activated Allow Localhost Loopback in about:flags.
Does anybody what could be the problem?
Not sure about the root cause of the problem, but here are some options to work around this:
Configure VM Networking to be Bridged rather than NAT;
Use a proxy, e.g. Fiddler;
Port forward, using netsh, ssh or other utilities.
For option 2 and 3, see this answer for details.
I have the same problem and can't find a workaroud -- even after 2 years. I guess the final answer is: Stop using Edge.
Looks like Microsoft is dumping it: [https://arstechnica.com/gadgets/2018/12/post-mortem-tying-edge-to-windows-10-was-a-fatal-error/]
Go to the start menu and type "Internet Options" Select internet options and open he security tab click on Local Intranet then press the sites button.
Control Panel > Internet Options > Security > Local Intranet > Sites
Uncheck "include all local (intranet) sites not listed in other zones" and "Include all sites that bypass the proxy server".
Restart Edge and try again.
If your machine with the webserver has internet access you could use a tool like ngrok to create a tunnel with a public URL to your machine.
http://www.sitepoint.com/use-ngrok-test-local-site/
I'm running the latest win 10 V 1809 build 17763.253.
I have checked several threads that don't show any solution, but I found one thread with a workaround by adding the local IP range to the trusted sites, it works for me.
Second workaround is using the server name instead of the IP address.
Example: http://Computer-name/ which gets resolved to IP version 6 address.
Since this is bug only happens with MS EDGE and works fine with all other browsers, where is the official MS solution ?
enter image description here

Starting up Worklight Server

I am trying to run a simple HelloWorld app on my MacBook using Eclipse Luna and I am getting this message:
The current server configuration is set to "localhost". Therefore the
Worklight build uses the primary IP address of this computer
(???.???.?.???) instead. It is recommended to set the server
configuration to use the fully qualified hostname or IP address of
this computer. To configure the setting, in the "Servers" view
double-click the Worklight Development Server entry and edit the "Host
name" field.
Clicking the Worklight Development Server opens a sub menu with different files. I believe that I need to replace localhost by my IP address. Which file and which entry need to be modified?
It is only a recommendation and typically in most cases for local development there is no need to change this value.
If you still prefer to change it, it is where the message says so.
Open the Servers view and double-click on the "Worklight Development Server" entry (no need to expend it):
I just solved the same problem. I had to change the Host Name to the name of my PC and it worked.
#Simon, Can you do a DNS flush on your mac once and give it a try. Sometimes DNS flush causes some sort of unwanted issues which doesnt resolve the ip address and acts funny
refer :- link