Limit maximum user count per realm

I need to limit the maximum users that can be created inside a realm.

Unfortunately I couldn’t find any existing solutions. According to ChatGPT there was a realm setting named “Maximum User Count” in v15.0.2 but I couldn’t find any documentation about this.

Is there some existing solution for this or do we need to adjust the keycloak code accordingly?

Thanks for help in advance,
Karl

I’m not aware of there ever being such a limit. I think you could probably write a custom event listener to call the session.users().getUserCount(realm) every time there is REGISTER event or USER.CREATE admin event. There wouldn’t be a good way to limit it (how would you even notify the user?), but at least you could alert yourself when it hit the limit.

1 Like

I am user Docker and running Keycloak v21. Looking to limit the session count for for client.
There is a step in the Authentication setup that can be used = and a reference to the admin manual.

I setup but it fails to work.

I always get 'We are sorry …" error messages.