WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Cannot access local machine IP

Open ughstudios opened this issue 6 years ago • 4 comments

For some reason, if I try to ping my local machine's IP it cannot connect. I'm trying to setup a Ruby on Rails server, but it's unable to connect to my local windows postgres server. When I try to ping my local IP: 192.168.1.247 from the ubuntu machine (running on 172.217.15.78) it won't ping back. However, I can ping google just fine from the wsl ubuntu terminal.)

ughstudios avatar May 26 '20 17:05 ughstudios

You must set first the listen_addresses to * or your Ubuntu IP in postgresql.conf and set your pg_hba.conf so that it can accept incoming connection.

Example: psql

rescenic avatar May 26 '20 20:05 rescenic

Why not? My WSL2 can access my Win10 ip on my side.

# my win10 ip address
无线局域网适配器 WLAN:

   连接特定的 DNS 后缀 . . . . . . . :
   本地链接 IPv6 地址. . . . . . . . : fe80::48d4:9e9a:72cf:a94e%23
   IPv4 地址 . . . . . . . . . . . . : 192.168.1.107
   子网掩码  . . . . . . . . . . . . : 255.255.255.0
   默认网关. . . . . . . . . . . . . : 192.168.1.1

I hosted an API in my IIS of Win10, and I use curl command-line to access this api:

# on my WSL2 Ubuntu
$ curl http://192.168.1.107:8022/api/values
["value1","value2"]

It can retrieve the specified values.

Maybe you can refer this issue to config on your side. https://github.com/microsoft/WSL/issues/4150

simonmatt avatar May 28 '20 14:05 simonmatt

What's hilarious is I ended up figuring it out. Windows firewall actually blocks Ubuntu from WSL. Once I allow connection from the Ubuntu IP it all works fine.

ughstudios avatar May 28 '20 14:05 ughstudios

And this tool can help you to fix the issue you mentioned.

https://github.com/shayne/wsl2-hacks

simonmatt avatar May 28 '20 14:05 simonmatt