org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres" (with Spring Boot)

I am facing an issue connecting my Spring Boot application to a Postgres server which is running by Docker. Here is my application.properties file:

spring.application.name=warehouse-management
server.port=8081
spring.datasource.url=jdbc:postgresql://localhost:5432/warehouse
spring.datasource.username=postgres
spring.datasource.password=admin
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

With the same username and password (postgres-admin), I am able to connect to the Postgres server using pgAdmin (which is also running by Docker), but for some reason, when I start the Spring Boot application, it throws this error. This is my "warehouse" database (through pgadmin) enter image description here

I have tried changing the password for the Postgres user, but it still does not work. I suspect the issue might be with the pg_hba.conf file. I have tried various methods such as trust, password, and scram_sha_256 (the default), but none of them resolve the issue. Two weeks ago, when I first ran the application, it connected and worked normally. I was able to test the APIs and perform CRUD operations on the Postgres database. However, today when I opened it again, it started throwing this error.

I would appreciate any assistance or guidance on resolving this issue.

Upvotes: 0

Views: 268

Answers (1)

Suraj Mane
Suraj Mane

Reputation: 49

have you add postgresql dependancy ? If not ,you will need to add and check https://mvnrepository.com/artifact/org.postgresql/postgresql

And which postgresSQL version you are using ? change postgressql dialect accordingly

Upvotes: -1

Related Questions