Failing to run KC 18.0.2 with Quarkus in prod (on vm oracle)

Hello,

I am trying keycloak in production mode; it successfully worked in dev mode. With this config below I get the following output. I am not sure where the problem comes from (postgres driver , config ip/port, other conf…)

Could someone help me with that please ?

[root@VMOracle keycloak-18.0.2]# ./bin/kc.sh show-config
Current Mode: none
Runtime Configuration:
kc.cache = ispn (PersistedConfigSource)
kc.config.args = show-config (SysPropConfigSource)
kc.db = postgres (PropertiesConfigSource[source=file:/home/userna/keycloak-18.0.2/bin/…/conf/keycloak.conf])
kc.db-password = ******* (PropertiesConfigSource[source=file:/home/userna/keycloak-18.0.2/bin/…/conf/keycloak.conf])
kc.db-url = jdbc:postgresql://localhost:5432/keycloak (PropertiesConfigSource[source=file:/home/userna/keycloak-18.0.2/bin/…/conf/keycloak.conf])
kc.db-username = admin (PropertiesConfigSource[source=file:/home/userna/keycloak-18.0.2/bin/…/conf/keycloak.conf])
kc.health-enabled = true (PropertiesConfigSource[source=file:/home/userna/keycloak-18.0.2/bin/…/conf/keycloak.conf])
kc.home.dir = /home/userna/keycloak-18.0.2/bin/…/ (SysPropConfigSource)
kc.hostname = keycloak (PropertiesConfigSource[source=file:/home/userna/keycloak-18.0.2/bin/…/conf/keycloak.conf])
kc.http-enabled = false (PropertiesConfigSource[source=jar:file:///home/userna/keycloak-18.0.2/lib/lib/main/org.keycloak.keycloak-quarkus-server-18.0.2.jar!/META-INF/keycloak.conf])
kc.http-relative-path = / (PersistedConfigSource)
kc.https-certificate-file = /home/userna/keycloak-18.0.2/bin/…/conf/server.pem (PropertiesConfigSource[source=file:/home/userna/keycloak-18.0.2/bin/…/conf/keycloak.conf])
kc.https-certificate-key-file = /home/userna/keycloak-18.0.2/bin/…/conf/serverkey.pem (PropertiesConfigSource[source=file:/home/userna/keycloak-18.0.2/bin/…/conf/keycloak.conf])
kc.log-console-output = default (PropertiesConfigSource[source=jar:file:///home/userna/keycloak-18.0.2/lib/lib/main/org.keycloak.keycloak-quarkus-server-18.0.2.jar!/META-INF/keycloak.conf])
kc.log-file = /home/userna/keycloak-18.0.2/bin/…/data/log/keycloak.log (PropertiesConfigSource[source=jar:file:///home/userna/keycloak-18.0.2/lib/lib/main/org.keycloak.keycloak-quarkus-server-18.0.2.jar!/META-INF/keycloak.conf])
kc.metrics-enabled = true (PropertiesConfigSource[source=file:/home/userna/keycloak-18.0.2/bin/…/conf/keycloak.conf])
kc.quarkus-properties-enabled = false (PersistedConfigSource)
kc.show.config = none (SysPropConfigSource)
kc.version = 18.0.2 (SysPropConfigSource)

[root@VMOracle bin]# ./kc.sh start
2022-07-25 14:59:51,415 INFO [org.keycloak.quarkus.runtime.hostname.DefaultHostnameProvider] (main) Hostname settings: FrontEnd: keycloak, Strict HTTPS: true, Path: , Strict BackChannel: false, Admin: , Port: -1, Proxied: false
2022-07-25 14:59:51,622 WARN [io.agroal.pool] (agroal-11) Datasource ‘’: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2022-07-25 14:59:51,624 WARN [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.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:319)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.(PgConnection.java:223)
at org.postgresql.Driver.makeConnection(Driver.java:400)
at org.postgresql.Driver.connect(Driver.java:259)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:103)
at org.postgresql.xa.PGXADataSource.getXAConnection(PGXADataSource.java:49)
at org.postgresql.xa.PGXADataSource.getXAConnection(PGXADataSource.java:35)
at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:216)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:513)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:494)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1126)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at org.postgresql.core.PGStream.createSocket(PGStream.java:241)
at org.postgresql.core.PGStream.(PGStream.java:98)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:109)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:235)
… 17 more

2022-07-25 14:59:52,383 WARN [org.infinispan.PERSISTENCE] (keycloak-cache-init) ISPN000554: jboss-marshalling is deprecated and planned for removal
2022-07-25 14:59:52,442 WARN [io.agroal.pool] (agroal-11) Datasource ‘’: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2022-07-25 14:59:52,479 WARN [org.infinispan.CONFIG] (keycloak-cache-init) ISPN000569: Unable to persist Infinispan internal caches as no global state enabled
2022-07-25 14:59:52,508 INFO [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000556: Starting user marshaller ‘org.infinispan.jboss.marshalling.core.JBossUserMarshaller’
2022-07-25 14:59:52,677 INFO [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000128: Infinispan version: Infinispan ‘Triskaidekaphobia’ 13.0.9.Final
2022-07-25 14:59:52,779 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000078: Starting JGroups channel ISPN
2022-07-25 14:59:52,779 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000088: Unable to use any JGroups configuration mechanisms provided in properties {}. Using default JGroups configuration!
2022-07-25 14:59:52,854 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the send buffer of socket MulticastSocket was set to 1.00MB, but the OS only allocated 212.99KB
2022-07-25 14:59:52,854 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the receive buffer of socket MulticastSocket was set to 20.00MB, but the OS only allocated 212.99KB
2022-07-25 14:59:52,854 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the send buffer of socket MulticastSocket was set to 1.00MB, but the OS only allocated 212.99KB
2022-07-25 14:59:52,854 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the receive buffer of socket MulticastSocket was set to 25.00MB, but the OS only allocated 212.99KB
2022-07-25 14:59:54,866 INFO [org.jgroups.protocols.pbcast.GMS] (keycloak-cache-init) VMOracle-49683: no members discovered after 2004 ms: creating cluster as coordinator
2022-07-25 14:59:54,878 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000094: Received new cluster view for channel ISPN: [VMOracle-49683|0] (1) [VMOracle3-49683]
2022-07-25 14:59:54,885 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000079: Channel ISPN local address is VMOracle-49683, physical addresses are [10.0.0.43:39743]
2022-07-25 14:59:55,387 INFO [org.infinispan.CLUSTER] (main) ISPN000080: Disconnecting JGroups channel ISPN
2022-07-25 14:59:55,571 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (production) mode
2022-07-25 14:59:55,571 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to obtain JDBC connection
2022-07-25 14:59:55,572 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2022-07-25 14:59:55,572 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Connection refused (Connection refused)
2022-07-25 14:59:55,572 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details run the same command passing the ‘–verbose’ option. Also you can use ‘–help’ to see the details about the usage of the particular command.
[root@VMOracle bin]#

Read your stacktrace und compare with your config!

You’ve set your DB url to jdbc:postgresql://localhost:5432/keycloak - and your server can’t connect to a postgres DB on localhost on port 5432 :man_shrugging:

1 Like

Thank you for the answer I fixed it and I can now see the Welcome page :slight_smile:

However when I go to the admin login interface, the page is looping on itself, do you have an idea how to fix this ?

Thank you for your time and sorry for the inconvenience (Im new to this)!

PS: here is the output of kc.sh start

2022-07-26 15:21:19,635 INFO [org.keycloak.quarkus.runtime.hostname.DefaultHostnameProvider] (main) Hostname settings: FrontEnd: keycloak, Strict HTTPS: true, Path: , Strict BackChannel: false, Admin: , Port: -1, Proxied: false
2022-07-26 15:21:20,710 WARN [org.infinispan.PERSISTENCE] (keycloak-cache-init) ISPN000554: jboss-marshalling is deprecated and planned for removal
2022-07-26 15:21:20,754 WARN [org.infinispan.CONFIG] (keycloak-cache-init) ISPN000569: Unable to persist Infinispan internal caches as no global state enabled
2022-07-26 15:21:20,807 INFO [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000556: Starting user marshaller ‘org.infinispan.jboss.marshalling.core.JBossUserMarshaller’
2022-07-26 15:21:21,128 INFO [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000128: Infinispan version: Infinispan ‘Triskaidekaphobia’ 13.0.9.Final
2022-07-26 15:21:21,256 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000078: Starting JGroups channel ISPN
2022-07-26 15:21:21,256 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000088: Unable to use any JGroups configuration mechanisms provided in properties {}. Using default JGroups configuration!
2022-07-26 15:21:21,338 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the send buffer of socket MulticastSocket was set to 1.00MB, but the OS only allocated 212.99KB
2022-07-26 15:21:21,338 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the receive buffer of socket MulticastSocket was set to 20.00MB, but the OS only allocated 212.99KB
2022-07-26 15:21:21,338 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the send buffer of socket MulticastSocket was set to 1.00MB, but the OS only allocated 212.99KB
2022-07-26 15:21:21,339 WARN [org.jgroups.protocols.UDP] (keycloak-cache-init) JGRP000015: the receive buffer of socket MulticastSocket was set to 25.00MB, but the OS only allocated 212.99KB
2022-07-26 15:21:23,357 INFO [org.jgroups.protocols.pbcast.GMS] (keycloak-cache-init) VMOracle-19782: no members discovered after 2003 ms: creating cluster as coordinator
2022-07-26 15:21:23,367 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000094: Received new cluster view for channel ISPN: [VMOracle-19782|0] (1) [VMOracle-19782]
2022-07-26 15:21:23,378 INFO [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000079: Channel ISPN local address is VMOracle-19782, physical addresses are [10.0.0.43:46211]
2022-07-26 15:21:23,923 INFO [org.keycloak.connections.infinispan.DefaultInfinispanConnectionProviderFactory] (main) Node name: VMOracle-19782, Site name: null
2022-07-26 15:21:24,484 ERROR [org.keycloak.services] (main) KC-SERVICES0010: Failed to add user ‘admin’ to realm ‘master’: user with username exists
2022-07-26 15:21:24,916 INFO [io.quarkus] (main) Keycloak 18.0.2 on JVM (powered by Quarkus 2.7.5.Final) started in 8.087s. Listening on: https://0.0.0.0:8443
2022-07-26 15:21:24,917 INFO [io.quarkus] (main) Profile prod activated.
2022-07-26 15:21:24,917 INFO [io.quarkus] (main) Installed features: [agroal, cdi, hibernate-orm, jdbc-h2, jdbc-mariadb, jdbc-mssql, jdbc-mysql, jdbc-oracle, jdbc-postgresql, keycloak, narayana-jta, reactive-routes, resteasy, resteasy-jackson, smallrye-context-propagation, smallrye-health, smallrye-metrics, vault, vertx]