Uncaught Error: Packeger is not running at {host_ip}
See original GitHub issue// host_ip = 192.168.0.141 // wsl_ip = 172.17.132.182 //phone_ip = 192.168.0.64
Actually I am able to run my expo application without problems when using Ubuntu 18.04 through WSL 1. After Microsoft released the version 20.04, I decided to give it a try to use WSL 2 and run my application from there, but since network approach that WSL 2 uses is different from WSL 1, I am not able to access the application (this is my honest guest).
I had tried the following troubleshooting, but none of them had worked so far:
Disable Firewall on Windows 10 and Ubuntu 18.04 (through WSL 2).
-
Make sure that my phone is connected to the same network of the host machine, and that I can ping the host machine from WSL2 ( I have to mention that before disabling the firewall I was not able to ping the host machine).
-
Once I run
expo start
the project starts without problems at {wsl_ip}, however, I get the following response:
Uncaught Error: java.net.SocketTimeoutException: failed to connect to /172.17.132.182(port 19000) from /192.168.0.64 (port 43609) after 10000ms
After noticing that the project should be running in the localhost (host_ip) address I try the next step:
- Changing environment variable REACT_NATIVE_PACKAGER_HOSTNAME on WSL2 to 127.0.0.1, but I get as a response:
Uncaught Error: java.net.ConnectException: Failed to connect to http://127.0.0.1:19000
Since it was not able to connect I change the environment variable to the {host_ip} as follows:
- Changing REACT_NATIVE_PACKAGER_HOSTNAME to 192.168.0.141, but I get as a response:
Uncaught Error: Packeger is not running at http://192.168.0.141:19001
I have tried everything I saw on the issue #1381, but none of then had worked. Do you have anything else in mind that I should try?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
I needed the same and ran into same issues.
Here’s the full of what I found worked for LAN development between my mobile and expo running in WSL2:
1. One time at the start: open Expo ports inbound in Windows Firewall
Windows firewall should be on, and it should block inbound attempts by default. The following will open the Expo ports 19000–19006, inbound, but only on a network that you have configured as “private” (that’s the
-Profile Private
part): (powershell)(You can check it after with
Get-NetFirewallRule |Where-Object {$_.DisplayName -Match "Expo.*"}
)2. Point
portproxy
to WSL; Re-run “Each time WSL has a new IP address”(I’m not sure yet how often the WSL IP address changes, but I suspect only a reboot would)
I saw stuff on the web saying portproxy to
connectaddress=127.0.0.1
but it did not work for me (WSL2, Windows 10 20H2).So here’s a reusable command to auto set the connectaddress to the right WSL address: (powershell, just for the easy inline
Trim()
)3. Point Metro to your dev machine LAN IP Address; Re-run inside WSL “Each time dev host has a new IP address”
This is the one that probably changes most often. Your laptop local network IP certainly changes when you change networks (e.g. home/office) — and can change at other times too.
Fortunately it’s also pastable / aliasable: WSL2 shell
(If your dev box doesn’t change LAN often, you might get away with setting REACT_NATIVE_PACKAGER_HOSTNAME in your .bashrc / .zshrc)
I “wish I didn’t have to re-run things and it could all be automated”,
but that same laziness makes me happy to have commands 2 and 3 able to simple “rerun” and consistently get Expo LAN mode working for my WSL2-hosted Expo dev mode.
Hi @franciscosuca! I’m running WSL too, but I haven’t figured out the fix for this issue. Basically what happens is, your WSL container gets a custom IP that is ported/tunneled to your host (Windows) environment. This works fine if you use the tools on Windows itself, e.g. an Android virtual device. But not so much for any other device unfortunately 😢
A workaround that I often use for computers where I can’t access the IP directly (e.g. WSL or remote server) is switching to tunnels. With this, you should be able to connect to your WSL running bundler from your phone 😄
Hope it helps!