Reputation: 21
I’m trying to connect to Postgresql database that is in the same network with my computer using Java application. When I was using localhost (or 127.0.0.1) all works fine, but when I replaced it with the local IP of my computer, the connection refused error occurred. I edited the pg_hba.conf file:
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 192.168.0.0/16 trust
host all all 127.0.0.1/24 trust
# IPv6 local connections:
host all all ::1/128 trust
host all all fe80::/10 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 192.168.1.15/24 trust
host replication all ::1/128 trust
host duplicate all fe80::/10 trust
The listen_addresses in postgresql.conf:
#listen_addresses = ‘*’ # what IP address(es) to listen on;
So I still can not connect to the DB. When i removed this from pg_hba.conf
local all all trust
The connection refused error occurred event when I used localhost / 127.0.0.1 to connect. Thank you for any help.
Upvotes: 2
Views: 4468
Reputation: 1955
this is a comment
#listen_addresses = ‘*’ # what IP address(es) to listen on;
change it to
listen_addresses = ‘*’ # what IP address(es) to listen on;
restart the postgres server and everything else is fine.
Hope this helps !
Upvotes: 1