'uncaught-error-java-net-connectexception: failed to connect to /192.168.1.2 (port 19000) from 192.168.1.5 (port 42176)

I am running react native project from WSL2. I followed the steps in this blog https://hinty.io/devforth/how-to-install-wsl-2-best-way-to-run-real-linux-on-windows/ to install WSL and ubuntu. and I enabled the CPU virtualization and windows server Linux feature, then I installed node and yarn in WSL2.

To run the project:

  • cd to project path
  • set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.2
  • yarn start or expo start

when I open it from expo app on my mobile I have that error uncaught-error-java-net-connectexception: failed to connect to /192.168.1.2 (port 19000) from 192.168.1.5 (port 42176) knowing that I already check my IP from cmd command ipconfig and the Wireless LAN adapter Wi-Fi: IPv4 Address. . . . . . . . . . . : 192.168.1.2

Any help why I have that error and how to fix it?



Solution 1:[1]

Okay for me the solution was to run a ps1 file from the administrator PowerShell. This file is used to:

  • Delete old firewall rules it has created.
  • Create new firewall rules for the port forwarding
  • Delete all old port forwarding rules(if reset=1)
  • Create/replace port forwarding rules based on WSL2's current IP address

Solution 2:[2]

I got same error. and i changed on firewall configuration. i make all incoming request are allow and its has solved.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Menna Magdy
Solution 2 santosh