0

I have pgAdmin4 and postgresql installed separately on my Mac server. and I have a Spring boot application running in docker container in local

from application, I'm trying to give localhost:5433 in the connection string jdbc:postgresql://localhost:5433/database1. However it is not connecting.

error

Could not open JDBC Connection for transaction; nested exception is org.postgresql.util.PSQLException: Connection to 127.0.0.1:5433 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

can someone please help.

Also, I noticed my /usr/local/var/postgres/postgresql.conf and /Library/PostgreSQL/14/data/postgresql.conf are also not matching. do we need to have these two in sync?

Teletubbies
  • 43
  • 10

1 Answers1

1

change localhost to host.docker.internal it should work i.e.

change jdbc:postgresql://localhost:5433/database1 into jdbc:postgresql://host.docker.internal:5433/database1

btw, postgresql default port is 5432 if I'm not forgetting, so may be you'll need to change the port number if you haven't explicitly set it to 5433

Aurangzeb
  • 1,537
  • 13
  • 9