无法连接到VirtualBox客户端上的PostgreSQL

当我尝试从主机系统上的PostgreSQL客户端连接到VirtualBox客户系统上的PostgreSQL服务器时,出现“连接尝试失败”消息。

主机系统是Windows XP。 我正在运行VirtualBox 3.1.2。 客户系统是Ubuntu 9.10 Karmic Koala和PostgreSQL 8.4。

我已经在VirtualBox中转发了端口5432,如手册和本文中所述。 当我运行vboxmanage getextradata vmname enumerate ,我得到这些条目(除其他外):

 Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/pgsql/GuestPort, Value: 5432 Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/pgsql/HostPort, Value: 5432 Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/pgsql/Protocol, Value: TCP 

我使用这些条目在/etc/postgresql/8.4/main/pg_hba.conf中configuration了PostgreSQL安全性:

 # IPv4 local connections: host all all 127.0.0.1/32 md5 host all all 192.168.1.0/24 md5 host all all 10.0.2.2/32 md5 

然后我用sudo /etc/init.d/postgresql-8.4 reload加载PostgreSQL。

仅出于诊断目的 ,我禁用了我的Windows防火墙和我的Ubuntu防火墙( sudo ufw disable )。

有人知道我错过了什么步骤?

好吧,我发现这个post感谢了错过的一步。

我忘了在postgresql.conf中设置listen_addresses设置。 我正在使用这个值,但是可能会受到更多的限制:

 listen_addresses = '*' 

只是为了澄清,当从主机连接到PostgreSQL时,使用本地主机作为服务器和5432作为端口。 VirtualBox将把该端口转发给客户端。

我也意识到一些设置需要你重新启动PostgreSQL而不是重新加载它。 该命令是:

 sudo /etc/init.d/postgresql-8.4 restart