2017-06-05 73 views
0

我在我的主机(Mac OS)中运行postgresql实例。我能够通过JDBC在我的Spring Boot应用程序中使用localhost属性访问此实例。连接到在主机操作系统上运行的Postgrsql数据库

现在我已安装了一个来宾Ubuntu Virtual Box操作系统。我想从这个操作系统安装相同的实例。

所以我只是将相同应用程序的数据源url从localhost更改为主机ip和端口。 但是现在,当我部署应用程序并尝试运行它时,出现“连接被拒绝”错误。

从客户操作系统(10.0.2.2 5432)到主机操作系统的Telnet工作正常。从我的pg_hba.conf文件

# TYPE DATABASE  USER   ADDRESS     METHOD 

# "local" is for Unix domain socket connections only 
local all    all          md5 
# IPv4 local connections: 
host all    all    127.0.0.1/32   md5 
# IPv6 local connections: 
host all    all    ::1/128     md5 
# Allow replication connections from localhost, by a user with the 
# replication privilege. 
#local replication  postgres        md5 
#host replication  postgres  127.0.0.1/32   md5 
#host replication  postgres  ::1/128     md5 
host all    all    0.0.0.0/0      md5 
host all    all    ::/0       md5 

连接和认证内容

内容从我的postgresql.conf

#------------------------------------------------------------------------------ 
# CONNECTIONS AND AUTHENTICATION 
#------------------------------------------------------------------------------ 

# - Connection Settings - 

listen_addresses = '*'    # what IP address(es) to listen on; 
        # comma-separated list of addresses; 
        # defaults to 'localhost'; use '*' for all 
        # (change requires restart) 
port = 5432    # (change requires restart) 
max_connections = 100   # (change requires restart) 
#superuser_reserved_connections = 3 # (change requires restart) 
#unix_socket_directories = '/tmp' # comma-separated list of directories 
        # (change requires restart) 
#unix_socket_group = ''   # (change requires restart) 
#unix_socket_permissions = 0777  # begin with 0 to use octal notation 
        # (change requires restart) 
#bonjour = off    # advertise server via Bonjour 
        # (change requires restart) 
#bonjour_name = ''   # defaults to the computer name 
        # (change requires restart) 

所以,我有我的配置实例postgrsql接受来自任何IP连接。

我在防火墙后面。

也许我仍然缺少出头

最好的问候, Saurav

回答

相关问题