Keycloak Internal Server Error when a user tries to register with an existing email

5.4k Views Asked by At

As the title says, when registering a new account within a realm there's no email uniqueness check and keycloak give an internal server error

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Violation of UNIQUE KEY constraint 'UK_DYKN684SL8UP1CRFEI6ECKHD7'. Cannot insert duplicate key in object 'dbo.USER_ENTITY'. The duplicate key value is (my_realm, [email protected]).

my realm settings are these

enter image description here

and duplicate emails switch is disabled.

how can I enforce a unique email check like the unique username one?

1

There are 1 best solutions below

0
Lúthien On

We had the same issue and even the developer who was assigned to the Jira ticket I created couldn't find it. Because the issue did not show up in a clean installation of Keycloak we suspected it to be data related, and I only found it after eliminating pretty much everything I could think of.

Solution: go to menu Configure > Authentication > tab: Flows > dropdown: Registration and set Profile Validation to ENABLED.

It was disabled in our case, which caused Keycloak to skip the email validation that the Realm settings > Login form suggests should be active.