keycloak initial login does not work with admin username and password

37.9k Views Asked by At

I cannot login to keycloak in the initial setup. I managed to run the server via /standalone.sh -b=0.0.0.0 command and when accessing it via http://x.x.x.x:8080 the login page doesn't allow me to login with admin/admin username and password. any hint is highly apreciated.

3

There are 3 best solutions below

0
On

If you are someone who have setup KeyCloak in Kubernetes then we can port-forward and access the localhost:8080/auth that is how I did the initial admin user setup.

kubectl port-forward svc/keycloak-http  -n <namespace> 8080:80
2
On

In order to create the initial administrator user you need to use add-user-keycloak.sh (.bat) script located in keycloak/bin with all other scripts. Run it before starting/restarting the server, so Keycloak could pick up the user: $ ./add-user-keycloak.sh -u admin -p password.

$ ./add-user-keycloak.sh --help will show you all the available options.

2
On

According to the latest keycloak documentation (today) there are two procedures for creating the first administrator credentials:

Creating the account on the local host

If your server is accessible from localhost, perform these steps. Procedure:

  1. In a web browser, go to the http://localhost:8080 URL.
  2. Supply a username and password that you can recall in the Welcome page enter image description here

Creating the account remotely

If you cannot access the server from a localhost address, or just want to start Keycloak from the command line, use the KEYCLOAK_ADMIN and KEYCLOAK_ADMIN_PASSWORD environment variables to create an initial admin account.

For example:

export KEYCLOAK_ADMIN=<username>
export KEYCLOAK_ADMIN_PASSWORD=<password>

bin/kc.[sh|bat] start