Issue
I'm trying to connect my Spring Boot application to a remote PostgreSQL server database.
My application.properties file has the following:
server.port=8102
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql:192.168.4.33:5432/postgres
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=postgres
spring.datasource.password=secretpassword
spring.jpa.show-sql=true
logging.level.org.springframework.web=debug
logging.level.org.hibernate=debug
spring.jpa.generate-ddl=true
However, when I try to run my app, it comes out with the following error:
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'm not sure why Spring Boot is trying to use localhost still as I'm sure I've specifically asked it to use the IP address instead.
Solution
you have connection refuse.please make sure your database up and correct username and pass.or network is ok.
jdbc:postgresql://HOST:PORT/activitydb
Answered By - zahra souri
Answer Checked By - Katrina (JavaFixing Volunteer)