Keycloak is Ignoring --db-url Option

2.4k Views Asked by At

I'm trying to integrate my Keycloak server with Postgres, and ran into an odd problem. When starting my keycloak server with the provided command on Ubuntu:

./kc.sh start-dev --http-port ${PORT} --db-url=jdbc:postgres://myurl.com/database --db=postgres --db-schema auth --db-username postgres --db-password password

I get the following error:

[org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator] (JPA Startup Thread: keycloak-default) HHH000342: Could not obtain connection to query metadata: 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.

But of course, shown above, my database isn't on localhost, and I set the --db-url option accordingly. This makes me think keycloak is ignoring --db-url, as localhost:5432 is the default value for a Postgres connection.

Does anyone know why this might be happening?

EDIT: Running Keycloak version 19.0.1

1

There are 1 best solutions below

0
Eamonn Kenny On

The JDBC is should be:

--db-url=jdbc:postgresql://myurl.com/database

not:

--db-url=jdbc:postgres://myurl.com/database