Failed to add user 'admintest' to realm 'master': user with username exists

Hello,

I can access the welcome page however I cannot access the login page that loop on itself.
The environment variables are declared as :

export KEYCLOAK_ADMIN=admin
export KEYCLOAK_ADMIN_PASSWORD=passw

before to start kc. Here is the output I have when I do kc.sh:

./kc.sh start-dev
2022-07-27 12:41:16,948 INFO [org.keycloak.quarkus.runtime.hostname.DefaultHostnameProvider] (main) Hostname settings: FrontEnd: keycloak, Strict HTTPS: false, Path: , Strict BackChannel: false, Admin: , Port: -1, Proxied: false
2022-07-27 12:41:17,949 WARN [org.infinispan.CONFIG] (keycloak-cache-init) ISPN000569: Unable to persist Infinispan internal caches as no global state enabled
2022-07-27 12:41:17,994 WARN [org.infinispan.PERSISTENCE] (keycloak-cache-init) ISPN000554: jboss-marshalling is deprecated and planned for removal
2022-07-27 12:41:18,016 INFO [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000556: Starting user marshaller ‘org.infinispan.jboss.marshalling.core.JBossUserMarshaller’
2022-07-27 12:41:18,414 INFO [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000128: Infinispan version: Infinispan ‘Triskaidekaphobia’ 13.0.9.Final
2022-07-27 12:41:18,940 INFO [org.keycloak.connections.infinispan.DefaultInfinispanConnectionProviderFactory] (main) Node name: node_967884, Site name: null
2022-07-27 12:41:19,914 ERROR [org.keycloak.services] (main) KC-SERVICES0010: Failed to add user ‘admin’ to realm ‘master’: user with username exists
2022-07-27 12:41:20,386 INFO [io.quarkus] (main) Keycloak 18.0.2 on JVM (powered by Quarkus 2.7.5.Final) started in 6.360s. Listening on: http://0.0.0.0:8080 and https://0.0.0.0:8443
2022-07-27 12:41:20,386 INFO [io.quarkus] (main) Profile dev activated.
2022-07-27 12:41:20,386 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]
2022-07-27 12:41:20,390 WARN [org.keycloak.quarkus.runtime.KeycloakMain] (main) Running the server in development mode. DO NOT use this configuration in production.

Wether I start kc in dev or in prod I have the same problem of the page not coming up.

Could someone help me with this please ?

Thank you for your time and consideration :slight_smile:

The log looks normal ( the initial admin user is only added on the first startup). I would guess that you are in a container env and are missing correct proxy and/or ingress setups…

1 Like

hi, I am not in a container env but in a vm, here is my conf/keycloak.conf file, the admin console keeps looping on itself, do you have any other ideas of what could cause that ?

cheers

# Basic settings for running in production. Change accordingly before deploying the server.

# Database

# The database vendor.
db=postgres

# The username of the database user.
db-username=keycloak

# The password of the database user.
db-password=password

# The full database JDBC URL. If not provided, a default URL is set based on the selected database vendor.
#db-url=jdbc:postgresql://localhost/keycloak

# Observability

# If the server should expose healthcheck endpoints.
health-enabled=true

# If the server should expose metrics endpoints.
metrics-enabled=true

# HTTP

# The file path to a server certificate or certificate chain in PEM format.
https-certificate-file=${kc.home.dir}conf/server.pem

# The file path to a private key in PEM format.
https-certificate-key-file=${kc.home.dir}conf/serverkey.pem

# The proxy address forwarding mode if the server is behind a reverse proxy.
proxy=edge

# Do not attach route to cookies and rely on the session affinity capabilities from reverse proxy
spi-sticky-session-encoder-infinispan-should-attach-route=false

# Hostname for the Keycloak server.
hostname=keycloak

If i ever have problems like you are having, I normally look at the page (in chrome/firefox) and run it in developer mode (f12) and look for errors.

I have had issues before where keycloak swapped from one version to another and where it used to have a /auth/ the / wasnt present, and this was fixed after i changed my wildfly config.

With the quarkus version i had similar issues (spinning front end) when sitting behind a proxy. This again was due to my configuration. I run it behind an F5 that load balances to two instances, which are behind haproxy. I needed to ensure that my hostname was set correctly (to the front door), because otherwise it was trying to go to the local instance which wasnt accessible.

So i think try and see what clues you can get from crhome/firefox and then adjust your config.

1 Like

That was the problem actually, I also run behind haproxy and I didnt configure the hostname correctly in its conf :slight_smile:
cheers