无法在 Windows 10 中的 Hyper-V 之上访问 Linux Ubuntu 中的 PostgreSQL 运行
Unable to access PostgreSQL running in Linux Ubuntu on top of Hyper-V in Windows 10
我在 Windows 10 上的 Hyper-V 之上的 Linux 中遇到无法访问 PostgreSQL 运行 的令人困惑的错误。
下面是我的hb_pga.conf
的一部分。我已经使用 psql show hba_file
检查了它,我编辑了正确的配置文件。
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::1/128 md5
如果我添加 listen_addresses='*'
,我无法从 linux 虚拟机本身(也不是 Windows 主机)访问它。但是,如果我删除 listen_addresses
,并通过 psql -h 127.0.0.1 -U postgres postgres
使用 IP 连接进行测试,它将起作用。
我正在使用默认开关并为安装了 samba 的驱动器添加另一个内部开关。不确定这是否意味着什么。
使用此命令检查所有打开的端口:
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 1368/postgres
127.0.0 不应该是 0.0.0.0 以允许从外部连接吗?
已解决。
事实证明,listen_address='*'
参数与 pg_hba.conf
在同一目录的不同文件中,即 postgresql.conf
将 listen_addresses='*'
添加到 postgresql.conf
解决了这个问题。
我都放在这里了,你需要吗https://medium.com/@swdev/quick-start-postgresql-on-linux-windows-and-hyper-v-bf5eef40eb84
我在 Windows 10 上的 Hyper-V 之上的 Linux 中遇到无法访问 PostgreSQL 运行 的令人困惑的错误。
下面是我的hb_pga.conf
的一部分。我已经使用 psql show hba_file
检查了它,我编辑了正确的配置文件。
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::1/128 md5
如果我添加 listen_addresses='*'
,我无法从 linux 虚拟机本身(也不是 Windows 主机)访问它。但是,如果我删除 listen_addresses
,并通过 psql -h 127.0.0.1 -U postgres postgres
使用 IP 连接进行测试,它将起作用。
我正在使用默认开关并为安装了 samba 的驱动器添加另一个内部开关。不确定这是否意味着什么。
使用此命令检查所有打开的端口:
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 1368/postgres
127.0.0 不应该是 0.0.0.0 以允许从外部连接吗?
已解决。
事实证明,listen_address='*'
参数与 pg_hba.conf
在同一目录的不同文件中,即 postgresql.conf
将 listen_addresses='*'
添加到 postgresql.conf
解决了这个问题。
我都放在这里了,你需要吗https://medium.com/@swdev/quick-start-postgresql-on-linux-windows-and-hyper-v-bf5eef40eb84