I have selenium running on my host machine, and my app is inside a docker container (inside WSL2).
I am trying to get the app connect to the selenium, that is listening on port 4445.
It used to work a few months ago, I think something changed in WSL.
Host is listening on 4445:
PS> netstat -ano | findstr :4445
TCP 0.0.0.0:4445 0.0.0.0:0 LISTENING 11604
TCP [::]:4445 [::]:0 LISTENING 11604
I can access selenium from the windows host machine:
>curl -X POST http://DESKTOP-HED9HVG:4445/wd/hub
{"state":".....}
but not from WSL2:
$ curl -X POST http://172.22.241.214:4445/wd/hub
curl: (7) Failed to connect to 172.22.241.214 port 4445: Connection refused
I tried several options for the ip that I used in curl:
ip addr
eth0 ip
$(hostname)
- ip addresses from the results of
ipconfig /all | findstr IPv4
- ip address result of
route -n | grep UG | head -n1 | awk '{print $2}'
I installed tcptraceroute on WSL and run it. This is the output:
$ tcptraceroute $(hostname) 4445
Selected device lo, address 127.0.0.1, port 53915 for outgoing packets
Tracing the path to DESKTOP-WXYZ1 (127.0.1.1) on TCP port 4445, 30 hops max
1 DESKTOP-WXYZ1.localdomain (127.0.1.1) [closed] 0.075 ms 0.082 ms 0.074 ms
By the way, pinging from WSL to host does work:
$ ping $(hostname)
PING DESKTOP-WXYZ1.localdomain (127.0.1.1) 56(84) bytes of data.
64 bytes from DESKTOP-WXYZ1.localdomain (127.0.1.1): icmp_seq=1 ttl=64 time=0.053 ms
I tried to disable completely the windows firewall, but it doesn't help. I also added a rule in "Windows Defender Firewall" to enable port 4445 specifically. It still didn't help
Info about WSL:
>wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Running 2
docker-desktop Running 2
docker-desktop-data Running 2
Any idea how to solve this?