Cannot access local machine IP
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.)
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:

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
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.
And this tool can help you to fix the issue you mentioned.
https://github.com/shayne/wsl2-hacks