Can't log in with keycloak to jupyterhub

Hello guys,

I installed jupytherhub on the docker. Everything is fine with docker configuration.

I enter my username and password with keycloak, but the server specific to my user does not start and I get the error below.

  500 : Internal Server Error
 Unhandled error starting server user1
You can try restarting your server from the home page 

My juptyerhub_config.py like this:

from oauthenticator.generic import GenericOAuthenticator

from jupyterhub.auth import Authenticator


c = get_config()


c.JupyterHub.authenticator_class = GenericOAuthenticator


c.GenericOAuthenticator.client_id = 'jupyterhub'

c.GenericOAuthenticator.client_secret = '.........................'

c.GenericOAuthenticator.oauth_callback_url = 'https://jupyter.......net/hub/oauth_callback'



c.GenericOAuthenticator.authorize_url = 'https://........net/realms/...../protocol/openid-connect/auth'

c.GenericOAuthenticator.token_url = 'https://.......net/realms/....../protocol/openid-connect/token'

c.GenericOAuthenticator.userdata_url = 'https://......../realms/....../protocol/openid-connect/userinfo'



c.GenericOAuthenticator.userdata_method = 'GET'

c.GenericOAuthenticator.scope = ['openid', 'profile', 'email']


c.GenericOAuthenticator.username_key = 'preferred_username'

c.Authenticator.admin_users = {'user1'}

After that error, when i run that command and refresh the page,

docker container exec -it jupyterhub useradd -m user1

The application works fine. But I can’t do this for every user. Is there a setting that automatically creates a logged in user?

There’s a Local version of the authenticator that should create local users for you:

However if you’re using Docker you could use DockerSpawner instead, you can start from this example:

Is there any other solution except dockerspawner?

By the way, can we use ldap instead of keycloak? If we choose to use ldap, can we solve this problem by just editing the config file?

Thank you for your support @manics.

Local authenticator solved my problem. New config file:

from oauthenticator.generic import LocalGenericOAuthenticator


c = get_config()


c.JupyterHub.authenticator_class = LocalGenericOAuthenticator


c.LocalGenericOAuthenticator.client_id = 'jupyterhub'

c.LocalGenericOAuthenticator.client_secret = '.........................'

c.LocalGenericOAuthenticator.oauth_callback_url = 'https://jupyter.......net/hub/oauth_callback'



c.LocalGenericOAuthenticator.authorize_url = 'https://........net/realms/...../protocol/openid-connect/auth'

c.LocalGenericOAuthenticator.token_url = 'https://.......net/realms/....../protocol/openid-connect/token'

c.LocalGenericOAuthenticator.userdata_url = 'https://......../realms/....../protocol/openid-connect/userinfo'



c.LocalGenericOAuthenticator.userdata_method = 'GET'

c.LocalGenericOAuthenticator.scope = ['openid', 'profile', 'email']

c.LocalGenericOAuthenticator.username_key = 'preferred_username'


c.LocalGenericOAuthenticator.create_system_users = True


c.Authenticator.admin_users = {'user1'}
c.JupyterHub.admin_access = True

NOTE: When the container is deleted or down in docker, the user’s work may be lost. Therefore, the /home path in the container should be mounted as a volume.

2 Likes