I'm working on a Spring boot project and i tried to connect my server to a postgresql database. When i run the program with my IDE (on my windows OS) it's working but when i make a jar file and run it on my ubuntu server virtual machine which host my DB it doesn't work.
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
I've check my firewall rules but still no sucess.
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
I make some research and I heard about the configuration files of postgresql to modify but it still doesn't work and i have no idea where the issue comes.
Below the lines that i've modified on postgresql.conf:
listen_addresses = '*' # what IP address(es) to listen on;
ssl = on
and for the pg_hba.conf:
local all postgres peer
local all kapitax trust
# TYPE DATABASE USER ADDRESS METHOD
#host all kapitax * password
#host all all 0.0.0.0/0 md5
# "local" is for Unix domain socket connections only
local all all * trust
# IPv4 local connections:
host all all * password
# IPv6 local connections:
host all all ::1/128 password
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all * md5
host replication all ::1/128 md5
The issue can comes from the applcation.properties code ?
spring.datasource.url= jdbc:postgresql://localhost:5432/kapitax
spring.datasource.username=kapitax
spring.datasource.password=kapitax
spring.jpa.hibernate.ddl-auto=create-drop
server.port=8090