我正在我的主机(Mac OS)中运行postgresql实例。我可以使用Spring Boot应用程序中的localhost属性通过JDBC访问此实例
现在我安装了一个来宾Ubuntu Virtual Box OS。我想从这个操作系统安装相同的实例。
所以我只是将同一个应用程序的数据源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
答案 0 :(得分:0)
我的Spring Boot和Cloud Foundry配置存在问题。这与Postgresql无关。
好奇的读者请前往No unique service maching interface error in Spring Boot Cloud Foundry error寻求解决方案