# Unable to login to admin console with admin user in externalDatabase deployment

**URL:** <https://forum.keycloak.org/t/unable-to-login-to-admin-console-with-admin-user-in-externaldatabase-deployment/21988>\
**Category:** Configuring the server\
**Tags:** admin-console, authentication\
**Created:** [May 8, 2023, 2:26pm UTC](https://forum.keycloak.org/t/unable-to-login-to-admin-console-with-admin-user-in-externaldatabase-deployment/21988 "2023-05-08T14:26:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgeek](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@jgeek](https://forum.keycloak.org/u/jgeek)\
**Post date:** [May 8, 2023, 2:26pm UTC](https://forum.keycloak.org/t/unable-to-login-to-admin-console-with-admin-user-in-externaldatabase-deployment/21988/1 "2023-05-08T14:26:47Z")

</div>

I am installing keycloak through a third party open source application called [camunda](https://github.com/camunda/camunda-platform-helm/blob/main/charts/camunda-platform/values.yaml). The installation is done through helm on k8s. Internally camunda uses bitnami keycloak helm chart for installation

With the below helm values file configuration (local) I am enabling keycloak, configuring an external postgres server and setting the admin user/password to `admin/admin`.  
When we navigate to the keycloak page ([http://localhost:18080](http://localhost:18080)) we see the keycloak welcome page. Accessing the “Administration Console” page navigates to the login screen. Logging in with `admin/admin` fails though with “Invalid username or password” error (screenshot attached).

The keycloak k8s pod does print the below logs indicating the login error.

Any inputs on what could be going wrong would be helpful? Thanks

**Keycloak Logs**

```auto
14:00:59,330 WARN [org.keycloak.events] (default task-2) type=LOGIN_ERROR, realmId=master, clientId=security-admin-console, userId=null, ipAddress=127.0.0.1, error=user_not_found, auth_method=openid-connect, auth_type=code, redirect_uri=http://localhost:18080/auth/admin/master/console/, code_id=e66f96be-3ebf-4da3-a354-2840e379a1ff, authSessionParentId=e66f96be-3ebf-4da3-a354-2840e379a1ff, authSessionTabId=GMIbo2jB2WE
14:00:59,835 WARN [org.keycloak.events] (default task-2) type=LOGIN_ERROR, realmId=master, clientId=admin-cli, userId=46da1e66-7f55-494f-93a1-d6a2861b4e73, ipAddress=10.42.0.58, error=invalid_user_credentials, auth_method=openid-connect, grant_type=password, client_auth_method=client-secret, username=admin, authSessionParentId=c3d1efbb-5ba2-4195-9926-c02ecc37b15d, authSessionTabId=poB-1DXKPcs

```

**Helm file**

```yaml
  keycloak:
    enabled: true
    postgresql:
      enabled: false
    externalDatabase:
      host: 192.168.1.7
      port: 5432
      user: admin
      database: postgres
      password: admin
    auth:
      adminUser: admin
      adminPassword: admin

```

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/1/10d04bf2d447457d832842b212b9b26ae71842cb.png)

---

<div class="post-metadata">

**Author:** ![jgeek](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@jgeek](https://forum.keycloak.org/u/jgeek)\
**Post date:** [May 9, 2023, 9:25am UTC](https://forum.keycloak.org/t/unable-to-login-to-admin-console-with-admin-user-in-externaldatabase-deployment/21988/2 "2023-05-09T09:25:38Z")

</div>

We observed that this issue appears only if we configure an externalDatabase to keycloak. We could login with admin/admin if the database is internally created by keycloak helm installation.

Also without the externalDatabase configuration we observed that the keycloak instance does not restart if the helm chart is uninstalled and installed again. It fails to connect with the database container. The error logged is shared below

1. Any idea what could be reason and how could we configure admin user when we have an external postgres database for keycloak?
2. Why does the keycloak instance fail to connect to postgres on restart? What configuration is missing?

Thanks.  
**Keycloak restart failure log**

```java
Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "bn_keycloak"
	at org.postgresql.jdbc@42.2.14//org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:525)
	at org.postgresql.jdbc@42.2.14//org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:146)
	at org.postgresql.jdbc@42.2.14//org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:197)
	at org.postgresql.jdbc@42.2.14//org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
	at org.postgresql.jdbc@42.2.14//org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:217)
	at org.postgresql.jdbc@42.2.14//org.postgresql.Driver.makeConnection(Driver.java:458)
	at org.postgresql.jdbc@42.2.14//org.postgresql.Driver.connect(Driver.java:260)
```

---

<div class="post-metadata">

**Author:** ![LilMonk](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/lilmonk/32/9504_2.png) [@LilMonk](https://forum.keycloak.org/u/LilMonk)\
**Post date:** [December 28, 2023, 8:56pm UTC](https://forum.keycloak.org/t/unable-to-login-to-admin-console-with-admin-user-in-externaldatabase-deployment/21988/3 "2023-12-28T20:56:56Z")

</div>

I was facing similar issue while install [bitnami/keycloak](https://artifacthub.io/packages/helm/bitnami/keycloak) helm chart. I first installed the chart using the default values which created the username: user and password:\<random\_value\>. Then I had to remove all the tables from the postgres and then do the helm chart install with modified auth adminUser and adminPassword values.  
I see your yaml the `externalDatabase` is inside `keycloak`.

```yaml
keycloak:
    enabled: true
    postgresql:
      enabled: false
    externalDatabase:
      host: 192.168.1.7
      port: 5432
      user: admin
      database: postgres
      password: admin
    auth:
      adminUser: admin
      adminPassword: admin

```

But in [camunda-platform values.yaml](https://github.com/camunda/camunda-platform-helm/blob/a2d2e18af80a217faa5de94a050e741adacf0ec9/charts/camunda-platform/values.yaml#L1649) it outside the `keycloak`. Try to check it.

And from the error

```auto
Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "bn_keycloak"

```

It seems that your provided postgres credential values are not been taken and its defaulting to the bitnami/postgres chart’s default value.
