我在我的主機(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