Facing ldap3.core.exceptions.LDAPSocketOpenError while integrating LDAP with JupyterHub

Configuration for LDAP in JupyterHub:

JupyterHub:
      authenticator_class: ldapauthenticator.LDAPAuthenticator
LDAPAuthenticator:
      server_address: {server_add}
      bind_dn_template:
        - uid={username},cn=users,cn=dept,dc=org,dc=org 
      valid_username_regex: ^[a-z]+$
      lookup_dn: true
      lookup_dn_search_user: 
      lookup_dn_search_password: 
      lookup_dn_search_filter: ({login_attr}={login})
      lookup_dn_user_dn_attribute: cn
      user_search_base: cn=users,cn=dept,dc=org,dc=org
      user_attribute: sAMAccountName

I have added ldap3 and jupyterhub-ldapauthenticator extensions. When I login, facing LDAPSocketOpenError.

Traceback (most recent call last):
      File "/usr/local/lib/python3.11/site-packages/tornado/web.py", line 1713, in _execute
        result = await result
                 ^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/jupyterhub/handlers/login.py", line 156, in post
        user = await self.login_user(data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/jupyterhub/handlers/base.py", line 810, in login_user
        authenticated = await self.authenticate(data)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/jupyterhub/auth.py", line 491, in get_authenticated_user
        authenticated = await maybe_future(self.authenticate(handler, data))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/ldapauthenticator/ldapauthenticator.py", line 361, in authenticate
        username, resolved_dn = self.resolve_username(username)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/ldapauthenticator/ldapauthenticator.py", line 236, in resolve_username
        conn = self.get_connection(
               ^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/ldapauthenticator/ldapauthenticator.py", line 314, in get_connection
        conn = ldap3.Connection(
               ^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/ldap3/core/connection.py", line 363, in __init__
        self._do_auto_bind()
      File "/usr/local/lib/python3.11/site-packages/ldap3/core/connection.py", line 387, in _do_auto_bind
        self.open(read_server_info=False)
      File "/usr/local/lib/python3.11/site-packages/ldap3/strategy/sync.py", line 57, in open
        BaseStrategy.open(self, reset_usage, read_server_info)
      File "/usr/local/lib/python3.11/site-packages/ldap3/strategy/base.py", line 146, in open
        raise exception_history[0][0]
    ldap3.core.exceptions.LDAPSocketOpenError: socket connection error while opening: [Errno 110] Connection timed out

It sounds like something is stopping JupyterHub from connecting to your LDAP server, e.g. maybe you’ve got a firewall or some other restriction?