As the title states, 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 springboot is trying to use localhost still as I'm sure I've specifically asked it to use the IP address instead?
CodePudding user response:
you have connection refuse.please make sure your database up and correct username and pass.or network is ok.
jdbc:postgresql://HOST:PORT/activitydb
CodePudding user response:
Make sure the URL is correct.
spring.datasource.url=jdbc:postgresql:192.168.4.33:5432/postgres
You should use spring.datasource.url=jdbc:postgresql://192.168.4.33:5432/postgres
if it doesn't work then I suggest looking at your firewall or checking if that port is open on the server.