我主要是在windows上开发的,但是我正在用WSL测试我的应用程序,因为我会把它推到linux服务器上。我当前的问题是将运行在WSL上的django应用程序连接到postgres上,运行在windows上。许多文章解释了如何连接到在WSL上运行的postgres,而不是反过来。
发布于 2021-05-13 01:16:19
我还不能测试所有这些,所以我们可能需要在这个答案中修改几个条目,但是下面是我推荐的步骤:
ping $(hostname).local
.如果这解决了IP地址,那么这是步骤1。如果没有,那么还有其他选择(参见this answer). )。
New-NetFirewallRule -DisplayName "WSL Ping" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow -Protocol ICMPv4
。然后再试一次ping $(hostname).local
。用Remove-NetFirewallRule -DisplayName "WSL Ping"
删除规则
New-NetFirewallRule -DisplayName "WSL PostgreSQL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow -Protocol TCP -LocalPort 5432
.一样
从WSL中的Django应用程序访问它。
https://stackoverflow.com/questions/67511282
复制相似问题