Can't login to Keycloak

Hi folks,

I’ve installed Keycloak using a docker-compose file.

version: '3'

      driver: local

      image: postgres
        - postgres_data:/var/lib/postgresql/data
       -  POSTGRES_DB=keycloak
       -  POSTGRES_USER=keycloak
       -  POSTGRES_PASSWORD=password
        - DB_ADDR=postgres
        - DB_DATABASE=keycloak
        - DB_USER=keycloak
        - DB_SCHEMA=public
        - DB_PASSWORD=password
        - KEYCLOAK_USER=admin
        - KEYCLOAK_PASSWORD=admin
        #JDBC_PARAMS: "ssl=true"
        - 8080:8080
        - postgres

I got the Keycloak running. But when I login, I got an error saying “Invalid username or password.”
I’ve used the credentials admin / admin for login.

If I remove volumes in postgres and do a docker-compose up it works fine. I don’t understand why it is not working if I use volumes. I do have the directories for the volume postgres_data in my server .
Can someone help me? Any help would be much appreciated.

Can you share the logs

Following is the logs I’m getting

WARN [] (default task-2) type=LOGIN_ERROR, realmId=master, clientId=security-admin-console, userId=0d8e6181-4a64-4d7f-8076-eb99dc2632ef, ipAddress=, error=invalid_user_credentials, auth_method=openid-connect, auth_type=code, redirect_uri=http://server/auth/admin/master/console/, code_id=c2ba5c26-cec7-4707-aae7-3c60b4729756, username=admin, authSessionParentId=c2ba5c26-cec7-4707-aae7-3c60b4729756, authSessionTabId=wxNUSryJJ24

Try to set another password other than ‘admin’, this will resolve your problem.
Seems like a bug or something else.

I changed the password. It didn’t work. Still get getting the same error.

I’ve tried it on my system, when I set the KEYCLOAK_PASSWORD to admin I can’t also login, when I change it to password I can login. My docker-compose file can be found under
My guess is that the username and password can’t be the same value, which from a security perspective makes sense but they should throw an error on startup

1 Like

Thanks for the Answer.

Just to register, on keycloak 20.0.1 one should set KEYCLOAK_ADMIN_PASSWORD instead of KEYCLOAK_PASSWORD. I haven’t checked earlier versions, but be warned. Starting docker keycloak using KEYCLOAK_PASSWORD makes it unable to login at Keycloak Admin Console and leads to errors like user_not_found and/or invalid_user_credentials.

1 Like

Worth to note that if you set an email address for the admin user, the username admin no longer will work to log in.