# USer Authentication failure: Unique index or primary key violation

**URL:** <https://forum.keycloak.org/t/user-authentication-failure-unique-index-or-primary-key-violation/21143>\
**Category:** Configuring the server\
**Created:** [March 29, 2023, 5:10am UTC](https://forum.keycloak.org/t/user-authentication-failure-unique-index-or-primary-key-violation/21143 "2023-03-29T05:10:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![A2P](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@A2P](https://forum.keycloak.org/u/A2P)\
**Post date:** [March 29, 2023, 5:10am UTC](https://forum.keycloak.org/t/user-authentication-failure-unique-index-or-primary-key-violation/21143/1 "2023-03-29T05:10:52Z")

</div>

I have inherited a test environment (airgapped server with no external access possible) running multiple containers in Docker. 1 Container is a web application, another is Keycloak. Keycloak is providing user authentication for the users of the web application.  
There is 1 realm and 2 users preconfigured in keycloak plus multiple roles. When I select impersonate for one of the users I get taken to the application, but the login fails.

In the log for keycloak I can see:

> "Unique index or primary key violation: “PRIMARY\_KEY\_62 ON PUBLIC.REALM(ID) VALUES (‘nca-realm’, 24)”\>

I have tried to look inside the H2 Database to look for the user record, however I am not convinced or sure H2 is in use. When I look at the standalone.xml file for datasources I can see the following:

 org.mariadb.jdbc.Driver org.h2.jdbcx.JdbcDataSource 

Does this confirm that H2 is in use or something else? if so how do I find the location of the H2 database to create a connection to is in the H2 Console.

Please note this is using an old version keyclock (18-2.0) and H2 1.4-193 - yes, I know it needs an upgrade, and eventually it will be but for now I need to get this instance working.

Thanks in advance
