# Tljh-reload stuck in infinite loop of Hub not ready: (HTTP status 502) InsecureRequestWarning: Unverified HTTPS request is being made to host while setting up azuread OAuthenticator

**URL:** <https://discourse.jupyter.org/t/tljh-reload-stuck-in-infinite-loop-of-hub-not-ready-http-status-502-insecurerequestwarning-unverified-https-request-is-being-made-to-host-while-setting-up-azuread-oauthenticator/22919>\
**Category:** The Littlest JupyterHub\
**Created:** [December 14, 2023, 9:18pm UTC](https://discourse.jupyter.org/t/tljh-reload-stuck-in-infinite-loop-of-hub-not-ready-http-status-502-insecurerequestwarning-unverified-https-request-is-being-made-to-host-while-setting-up-azuread-oauthenticator/22919 "2023-12-14T21:18:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahesh\_Mhatre](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahesh_mhatre/32/11842_2.png) [@Mahesh\_Mhatre](https://discourse.jupyter.org/u/Mahesh_Mhatre)\
**Post date:** [December 14, 2023, 9:18pm UTC](https://discourse.jupyter.org/t/tljh-reload-stuck-in-infinite-loop-of-hub-not-ready-http-status-502-insecurerequestwarning-unverified-https-request-is-being-made-to-host-while-setting-up-azuread-oauthenticator/22919/1 "2023-12-14T21:18:43Z")

</div>

While setting up OAuthenticator for azuread by following this documentation: [Azure AD Setup — OAuthenticator](https://oauthenticator.readthedocs.io/en/latest/tutorials/provider-specific-setup/providers/azuread.html)

sudo tljh-config reload is stuck in infinite loop of: Hub not ready: (HTTP status 502)  
/opt/tljh/hub/lib/python3.10/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host ‘127.0.0.1’. Adding certificate verification is strongly advised. See: [Advanced Usage - urllib3 0.1.dev50 documentation](https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings)  
warnings.warn(

and  
accessing the jupyterhub shows bad gateway exception in the browser. (mostly because relaod isn’t finished)

### How to reproduce

1. Create a JupyterHub
2. Enable https for it
3. In JupyterHub config:

```auto
auth:
    OAuthenticator:
        client_id: <client id created in azure ad using app registration>
        client_secret: <client secret created in azure ad using app registration>
    type: azuread
AzureAdOAuthenticator:
  tenant_id: <tenant id created in azure ad using app registration>
  scope: '[Read]'

```

1. Run: ‘sudo tljh-config reload’

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [December 15, 2023, 3:29pm UTC](https://discourse.jupyter.org/t/tljh-reload-stuck-in-infinite-loop-of-hub-not-ready-http-status-502-insecurerequestwarning-unverified-https-request-is-being-made-to-host-while-setting-up-azuread-oauthenticator/22919/2 "2023-12-15T15:29:36Z")

</div>

Can you show us your full configuration, and your JupyterHub logs?

---

<div class="post-metadata">

**Author:** ![Mahesh\_Mhatre](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahesh_mhatre/32/11842_2.png) [@Mahesh\_Mhatre](https://discourse.jupyter.org/u/Mahesh_Mhatre)\
**Post date:** [December 15, 2023, 6:29pm UTC](https://discourse.jupyter.org/t/tljh-reload-stuck-in-infinite-loop-of-hub-not-ready-http-status-502-insecurerequestwarning-unverified-https-request-is-being-made-to-host-while-setting-up-azuread-oauthenticator/22919/3 "2023-12-15T18:29:05Z")

</div>

Sure,  
the tljh-config file looks like:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/d/d91bcefae5eb53fbbf1dbd4eab555f15c4f2cb1f.png)

and the logs show this:  
Dec 15 18:18:45 JupyterHub python3[2671]: File “/usr/lib/python3.6/importlib/ **init**.py”, line 126, in import\_module  
Dec 15 18:18:45 JupyterHub python3[2671]: return \_bootstrap.\_gcd\_import(name[level:], package, level)  
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 994, in \_gcd\_import  
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 971, in \_find\_and\_load  
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 955, in \_find\_and\_load\_unlocked  
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 665, in \_load\_unlocked  
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 678, in exec\_module  
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 219, in \_call\_with\_frames\_removed  
Dec 15 18:18:45 JupyterHub python3[2671]: File “/opt/tljh/hub/lib/python3.6/site-packages/oauthenticator/azuread.py”, line  
Dec 15 18:18:45 JupyterHub python3[2671]: import jwt  
Dec 15 18:18:45 JupyterHub python3[2671]: ModuleNotFoundError: No module named ‘jwt’  
Dec 15 18:18:45 JupyterHub python3[2671]:  
Dec 15 18:18:45 JupyterHub systemd[1]: jupyterhub.service: Main process exited, code=exited, status=1/FAILURE  
Dec 15 18:18:45 JupyterHub systemd[1]: jupyterhub.service: Failed with result ‘exit-code’.  
Dec 15 18:18:46 JupyterHub systemd[1]: jupyterhub.service: Service hold-off time over, scheduling restart.  
Dec 15 18:18:46 JupyterHub systemd[1]: jupyterhub.service: Scheduled restart job, restart counter is at 4.  
Dec 15 18:18:46 JupyterHub systemd[1]: Stopped jupyterhub.service.  
Dec 15 18:18:46 JupyterHub systemd[1]: Started jupyterhub.service.  
Dec 15 18:18:47 JupyterHub python3[2720]: /opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/crypto.py:17: CryptographyDepreca  
Dec 15 18:18:47 JupyterHub python3[2720]: import cryptography  
Dec 15 18:18:47 JupyterHub python3[2720]: [E 2023-12-15 18:18:47.037 JupyterHub app:2991]  
Dec 15 18:18:47 JupyterHub python3[2720]: Traceback (most recent call last):  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/app.py”, line 2988, i  
Dec 15 18:18:47 JupyterHub python3[2720]: await self.initialize(argv)  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/app.py”, line 2478, i  
Dec 15 18:18:47 JupyterHub python3[2720]: self.load\_config\_file(self.config\_file)  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/decorator.py”, line 232, in fun  
Dec 15 18:18:47 JupyterHub python3[2720]: return caller(func, \*(extras + args), \*\*kw)  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/traitlets/config/application.py”  
Dec 15 18:18:47 JupyterHub python3[2720]: return method(app, \*args, \*\*kwargs)  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/traitlets/config/application.py”  
Dec 15 18:18:47 JupyterHub python3[2720]: self.update\_config(new\_config)  
Dec 15 18:18:47 JupyterHub python3[2720]: File "/opt/tljh/hub/lib/python3.6/site-packages/traitlets/config/configurable.py  
Dec 15 18:18:47 JupyterHub python3[2720]: self.\_load\_config(config)  
Dec 15 18:18:47 JupyterHub python3[2720]: File "/opt/tljh/hub/lib/python3.6/site-packages/traitlets/config/configurable.py  
Dec 15 18:18:47 JupyterHub python3[2720]: setattr(self, name, deepcopy(config\_value))  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/traitlets/traitlets.py”, line 58  
Dec 15 18:18:47 JupyterHub python3[2720]: self.set(obj, value)  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/traitlets/traitlets.py”, line 55  
Dec 15 18:18:47 JupyterHub python3[2720]: new\_value = self.\_validate(obj, value)  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/traitlets/traitlets.py”, line 59  
Dec 15 18:18:47 JupyterHub python3[2720]: value = self.validate(obj, value)  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/traitlets.py”, line 1  
Dec 15 18:18:47 JupyterHub python3[2720]: value = registry[key].load()  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/entrypoints.py”, line 79, in loa  
Dec 15 18:18:47 JupyterHub python3[2720]: mod = import\_module(self.module\_name)  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/usr/lib/python3.6/importlib/ **init**.py”, line 126, in import\_module  
Dec 15 18:18:47 JupyterHub python3[2720]: return \_bootstrap.\_gcd\_import(name[level:], package, level)  
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 994, in \_gcd\_import  
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 971, in \_find\_and\_load  
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 955, in \_find\_and\_load\_unlocked  
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 665, in \_load\_unlocked  
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 678, in exec\_module  
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 219, in \_call\_with\_frames\_removed  
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/oauthenticator/azuread.py”, line  
Dec 15 18:18:47 JupyterHub python3[2720]: import jwt  
Dec 15 18:18:47 JupyterHub python3[2720]: ModuleNotFoundError: No module named ‘jwt’  
Dec 15 18:18:47 JupyterHub python3[2720]:  
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Main process exited, code=exited, status=1/FAILURE  
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Failed with result ‘exit-code’.  
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Service hold-off time over, scheduling restart.  
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Scheduled restart job, restart counter is at 5.  
Dec 15 18:18:47 JupyterHub systemd[1]: Stopped jupyterhub.service.  
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Start request repeated too quickly.  
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Failed with result ‘exit-code’.  
Dec 15 18:18:47 JupyterHub systemd[1]: Failed to start jupyterhub.service.

---

<div class="post-metadata">

**Author:** ![Mahesh\_Mhatre](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahesh_mhatre/32/11842_2.png) [@Mahesh\_Mhatre](https://discourse.jupyter.org/u/Mahesh_Mhatre)\
**Post date:** [December 15, 2023, 6:30pm UTC](https://discourse.jupyter.org/t/tljh-reload-stuck-in-infinite-loop-of-hub-not-ready-http-status-502-insecurerequestwarning-unverified-https-request-is-being-made-to-host-while-setting-up-azuread-oauthenticator/22919/4 "2023-12-15T18:30:24Z")

</div>

looking at the ModuleNotFoundError: No module named ‘jwt’, installed the module but that didn’t help

---

<div class="post-metadata">

**Author:** ![mahendrapaipuri](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahendrapaipuri/32/6800_2.png) [@mahendrapaipuri](https://discourse.jupyter.org/u/mahendrapaipuri)\
**Post date:** [December 15, 2023, 7:04pm UTC](https://discourse.jupyter.org/t/tljh-reload-stuck-in-infinite-loop-of-hub-not-ready-http-status-502-insecurerequestwarning-unverified-https-request-is-being-made-to-host-while-setting-up-azuread-oauthenticator/22919/5 "2023-12-15T19:04:05Z")

</div>

What are the errors in the logs _after_ you installed `jwt`? Also, is it possible for you to upgrade Python? Your logs contain some deprecation errors from `crypography` maybe due to Python `3.6`!!

---

<div class="post-metadata">

**Author:** ![Mahesh\_Mhatre](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahesh_mhatre/32/11842_2.png) [@Mahesh\_Mhatre](https://discourse.jupyter.org/u/Mahesh_Mhatre)\
**Post date:** [December 20, 2023, 8:19pm UTC](https://discourse.jupyter.org/t/tljh-reload-stuck-in-infinite-loop-of-hub-not-ready-http-status-502-insecurerequestwarning-unverified-https-request-is-being-made-to-host-while-setting-up-azuread-oauthenticator/22919/7 "2023-12-20T20:19:25Z")

</div>

When I run python --version I get Python 3.9.7.

When I install PyJWT it gets installed in ./.local/lib/python3.9/site-packages

Why does oauthenticator installation happens inside **python3.6** /site-packages? I tried installing the PyJWT package for python3.6 to satisfy the requirement but running python3.6 -m pip install PyJWT still installs the package in python3.9.7

---

<div class="post-metadata">

**Author:** ![Mahesh\_Mhatre](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahesh_mhatre/32/11842_2.png) [@Mahesh\_Mhatre](https://discourse.jupyter.org/u/Mahesh_Mhatre)\
**Post date:** [December 20, 2023, 9:10pm UTC](https://discourse.jupyter.org/t/tljh-reload-stuck-in-infinite-loop-of-hub-not-ready-http-status-502-insecurerequestwarning-unverified-https-request-is-being-made-to-host-while-setting-up-azuread-oauthenticator/22919/8 "2023-12-20T21:10:24Z")

</div>

Update: PyJWT module must be installed in the hub environment using sudo /opt/tljh/hub/bin/python3 -m pip install. I was installing this module in user environment which was not helping
