Redirect loop detected. Notebook has jupyterhub version unknown (likely < 0.8), but the Hub expects 4.0.2

I installed JupyterHub on Ubutun 22.04, and generated the following jupyterhub_config.py:

c.JupyterHub.hub_port = 8000
c.JupyterHub.port = 8999
c.Authenticator.admin_users = { "root" }
c.DummyAuthenticatro.password = "baiguo"
c.Spawner.args = ["--allow-root"]

Then I run this command: jupyterhub -f jupyterhub_config.py, and open the url 127.0.0.1:8000. Then I get this error:


500 : Internal Server Error

Redirect loop detected. Notebook has jupyterhub version unknown (likely < 0.8), but the Hub expects 4.0.2. Try installing jupyterhub==4.0.2 in the user environment if you continue to have problems.

And this in the terminal:

 [W 2023-11-27 11:01:36.638 JupyterHub base:1656] Redirect loop detected on /hub/user/root/?redirects=1
[I 2023-11-27 11:01:36.772 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
[I 2023-11-27 11:01:38.641 JupyterHub log:191] 302 GET /hub/user/root/?redirects=1 -> /user/root/?redirects=2 (root@127.0.0.1) 2005.64ms
[I 2023-11-27 11:01:38.646 JupyterHub log:191] 302 GET /user/root/?redirects=2 -> /hub/user/root/?redirects=2 (@127.0.0.1) 0.79ms
[W 2023-11-27 11:01:38.651 JupyterHub web:1869] 500 GET /hub/user/root/?redirects=2 (127.0.0.1): Redirect loop detected. Notebook has jupyterhub version unknown (likely < 0.8), but the Hub expects 4.0.2. Try installing jupyterhub==4.0.2 in the user environment if you continue to have problems.
[E 2023-11-27 11:01:38.661 JupyterHub log:183] {
      "Host": "127.0.0.1:8000",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
      "Accept-Language": "en-US,en;q=0.5",
      "Accept-Encoding": "gzip, deflate, br",
      "Connection": "keep-alive",
      "Cookie": "jupyterhub-hub-login=[secret]; vue_admin_template_token=[secret]; username-127-0-0-1-8888=[secret]; _xsrf=[secret]; jupyterhub-session-id=[secret]",
      "Upgrade-Insecure-Requests": "1",
      "Sec-Fetch-Dest": "document",
      "Sec-Fetch-Mode": "navigate",
      "Sec-Fetch-Site": "cross-site"
    }
[E 2023-11-27 11:01:38.661 JupyterHub log:191] 500 GET /hub/user/root/?redirects=2 (root@127.0.0.1) 11.24ms
1 Like

For the redirect loop, make sure you always visit the public port of the deployment (c.JupyterHub.port, which is 8999 in your config), not the internal port for just the hub (which you’ve set to 8000, which also happens to be the default public port, but you’ve reassigned that to the be the private port).

1 Like

Thanks very much for your help. I changed the jupyterhub_config.py to this:

c.Spawner.args = ["--allow-root"]

And run the jupyterhub, and there is the terminal information:

I 2023-11-27 17:01:45.679 JupyterHub app:2859] Running JupyterHub version 4.0.2
[I 2023-11-27 17:01:45.679 JupyterHub app:2889] Using Authenticator: jupyterhub.auth.PAMAuthenticator-4.0.2
[I 2023-11-27 17:01:45.679 JupyterHub app:2889] Using Spawner: jupyterhub.spawner.LocalProcessSpawner-4.0.2
[I 2023-11-27 17:01:45.679 JupyterHub app:2889] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-4.0.2
[I 2023-11-27 17:01:45.681 JupyterHub app:1664] Loading cookie_secret from /root/jupyterhub_cookie_secret
[I 2023-11-27 17:01:45.723 JupyterHub proxy:556] Generating new CONFIGPROXY_AUTH_TOKEN
[I 2023-11-27 17:01:45.727 JupyterHub app:1984] Not using allowed_users. Any authenticated user will be allowed.
[I 2023-11-27 17:01:45.737 JupyterHub app:2928] Initialized 0 spawners in 0.001 seconds
[I 2023-11-27 17:01:45.740 JupyterHub metrics:278] Found 1 active users in the last ActiveUserPeriods.twenty_four_hours
[I 2023-11-27 17:01:45.741 JupyterHub metrics:278] Found 1 active users in the last ActiveUserPeriods.seven_days
[I 2023-11-27 17:01:45.741 JupyterHub metrics:278] Found 1 active users in the last ActiveUserPeriods.thirty_days
[W 2023-11-27 17:01:45.741 JupyterHub proxy:746] Running JupyterHub without SSL.  I hope there is SSL termination happening somewhere else...
[I 2023-11-27 17:01:45.742 JupyterHub proxy:750] Starting proxy @ http://:8000
17:01:45.829 [ConfigProxy] info: Proxying http://*:8000 to (no default)
17:01:45.830 [ConfigProxy] info: Proxy API at http://127.0.0.1:8001/api/routes
17:01:45.900 [ConfigProxy] info: 200 GET /api/routes
[I 2023-11-27 17:01:45.900 JupyterHub app:3178] Hub API listening on http://127.0.0.1:8081/hub/
17:01:45.901 [ConfigProxy] info: 200 GET /api/routes
[I 2023-11-27 17:01:45.901 JupyterHub proxy:477] Adding route for Hub: / => http://127.0.0.1:8081
17:01:45.902 [ConfigProxy] info: Adding route / -> http://127.0.0.1:8081
17:01:45.903 [ConfigProxy] info: Route added / -> http://127.0.0.1:8081
17:01:45.903 [ConfigProxy] info: 201 POST /api/routes/
[I 2023-11-27 17:01:45.903 JupyterHub app:3245] JupyterHub is now running at http://:8000

And then I opened the url http://127.0.0.1:8081/hub/user/root/. But I still get the same error as before:

[W 2023-11-27 17:08:23.043 JupyterHub _version:37] Single-user server has no version header, which means it is likely < 0.8. Expected 4.0.2
[I 2023-11-27 17:08:23.043 JupyterHub base:990] User root took 0.929 seconds to start
[I 2023-11-27 17:08:23.043 JupyterHub proxy:330] Adding user root to proxy /user/root/ => http://127.0.0.1:34779
17:08:23.045 [ConfigProxy] info: Adding route /user/root -> http://127.0.0.1:34779
17:08:23.045 [ConfigProxy] info: Route added /user/root -> http://127.0.0.1:34779
17:08:23.045 [ConfigProxy] info: 201 POST /api/routes/user/root
[I 2023-11-27 17:08:23.045 JupyterHub log:191] 302 GET /hub/spawn -> /hub/spawn-pending/root (root@127.0.0.1) 933.74ms
[I 2023-11-27 17:08:23.113 JupyterHub log:191] 302 GET /hub/spawn-pending/root -> /user/root/ (root@127.0.0.1) 1.75ms
[I 2023-11-27 17:08:23.182 JupyterHub log:191] 302 GET /user/root/ -> /hub/user/root/ (@127.0.0.1) 0.51ms
[I 2023-11-27 17:08:23.250 JupyterHub log:191] 302 GET /hub/user/root/ -> /user/root/?redirects=1 (root@127.0.0.1) 1.57ms
[I 2023-11-27 17:08:23.320 JupyterHub log:191] 302 GET /user/root/?redirects=1 -> /hub/user/root/?redirects=1 (@127.0.0.1) 0.53ms
[W 2023-11-27 17:08:23.433 JupyterHub base:1656] Redirect loop detected on /hub/user/root/?redirects=1
[I 2023-11-27 17:08:23.618 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
[I 2023-11-27 17:08:25.437 JupyterHub log:191] 302 GET /hub/user/root/?redirects=1 -> /user/root/?redirects=2 (root@127.0.0.1) 2004.91ms
[I 2023-11-27 17:08:25.507 JupyterHub log:191] 302 GET /user/root/?redirects=2 -> /hub/user/root/?redirects=2 (@127.0.0.1) 0.80ms
[W 2023-11-27 17:08:25.580 JupyterHub web:1869] 500 GET /hub/user/root/?redirects=2 (127.0.0.1): Redirect loop detected. Notebook has jupyterhub version unknown (likely < 0.8), but the Hub expects 4.0.2. Try installing jupyterhub==4.0.2 in the user environment if you continue to have problems.
[E 2023-11-27 17:08:25.592 JupyterHub log:183] {
      "Host": "127.0.0.1:8081",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
      "Accept-Language": "en-US,en;q=0.5",
      "Accept-Encoding": "gzip, deflate, br",
      "Connection": "keep-alive",
      "Cookie": "jupyterhub-hub-login=[secret]; vue_admin_template_token=[secret]; username-127-0-0-1-8888=[secret]; _xsrf=[secret]; jupyterhub-session-id=[secret]",
      "Upgrade-Insecure-Requests": "1",
      "Sec-Fetch-Dest": "document",
      "Sec-Fetch-Mode": "navigate",
      "Sec-Fetch-Site": "none",
      "Sec-Fetch-User": "?1"
    }
[E 2023-11-27 17:08:25.592 JupyterHub log:191] 500 GET /hub/user/root/?redirects=2 (root@127.0.0.1) 14.04ms

I found that information W 2023-11-27 17:08:23.043 JupyterHub _version:37] Single-user server has no version header, which means it is likely < 0.8. Expected 4.0.2. Is it related to the error?

Now that you’ve left the default ports, the URL you should use is http://127.0.0.1:8000/. The hub port (8081 by default) is exclusively for internal communication, and you should never make requests to it directly. Only the public port (8000 by default, override with c.JupyterHub.port) should ever be used.

1 Like

Can you share pip list and/or conda list for the environment you are using?

1 Like

This is the pip list output:

Package                   Version
------------------------- ----------------
aiofiles                  0.8.0
alembic                   1.12.1
anyio                     4.0.0
argon2-cffi               23.1.0
argon2-cffi-bindings      21.2.0
arrow                     1.3.0
asttokens                 2.4.1
async-generator           1.10
async-lru                 2.0.4
attrs                     23.1.0
Automat                   20.2.0
Babel                     2.13.1
bcrypt                    3.2.0
beautifulsoup4            4.12.2
bleach                    6.1.0
blinker                   1.4
certifi                   2020.6.20
certipy                   0.1.3
cffi                      1.16.0
chardet                   4.0.0
charset-normalizer        3.3.2
cliapp                    1.20180812.1
click                     8.0.3
cloud-init                23.3.1
colorama                  0.4.4
comm                      0.1.4
command-not-found         0.3
configobj                 5.0.6
constantly                15.1.0
cryptography              3.4.8
dbus-python               1.2.18
debugpy                   1.8.0
decorator                 5.1.1
defusedxml                0.7.1
distro                    1.7.0
distro-info               1.1+ubuntu0.1
exceptiongroup            1.1.3
executing                 2.0.1
fastjsonschema            2.18.1
fqdn                      1.5.1
greenlet                  3.0.1
gyp                       0.1
h11                       0.13.0
h2                        4.1.0
hpack                     4.0.0
httplib2                  0.20.2
hypercorn                 0.13.2
hyperframe                6.0.0
hyperlink                 21.0.0
idna                      3.3
importlib-metadata        4.6.4
incremental               21.3.0
ipykernel                 6.26.0
ipython                   8.17.2
ipython-genutils          0.2.0
isoduration               20.11.0
itsdangerous              2.1.0
jedi                      0.19.1
jeepney                   0.7.1
Jinja2                    3.0.3
json5                     0.9.14
jsonpatch                 1.32
jsonpointer               2.0
jsonschema                4.19.2
jsonschema-specifications 2023.7.1
jupyter_client            8.5.0
jupyter_core              5.5.0
jupyter-events            0.8.0
jupyter-lsp               2.2.0
jupyter_server            2.9.1
jupyter_server_terminals  0.4.4
jupyter-telemetry         0.1.0
jupyterhub                4.0.2
jupyterlab                4.0.8
jupyterlab-pygments       0.2.2
jupyterlab_server         2.25.0
keyring                   23.5.0
launchpadlib              1.10.16
lazr.restfulclient        0.14.4
lazr.uri                  1.0.6
Mako                      1.2.4
Markdown                  3.3.6
MarkupSafe                2.0.1
matplotlib-inline         0.1.6
mistune                   3.0.2
more-itertools            8.10.0
nbclassic                 1.0.0
nbclient                  0.8.0
nbconvert                 7.11.0
nbformat                  5.9.2
nest-asyncio              1.5.8
netifaces                 0.11.0
notebook                  7.0.6
notebook_shim             0.2.3
oauthlib                  3.2.0
overrides                 7.4.0
packaging                 23.2
pamela                    1.1.0
pandocfilters             1.5.0
parso                     0.8.3
pexpect                   4.8.0
pip                       22.0.2
platformdirs              3.11.0
priority                  1.3.0
prometheus-client         0.18.0
prompt-toolkit            3.0.39
psutil                    5.9.6
ptyprocess                0.7.0
pure-eval                 0.2.2
pyasn1                    0.4.8
pyasn1-modules            0.2.1
pycairo                   1.20.1
pycparser                 2.21
Pygments                  2.11.2
PyGObject                 3.42.1
PyHamcrest                2.0.2
pyinotify                 0.9.6
PyJWT                     2.3.0
pymacaroons               0.13.0
PyNaCl                    1.5.0
pyOpenSSL                 21.0.0
pyparsing                 2.4.7
pyrsistent                0.18.1
pyserial                  3.5
python-apt                2.4.0+ubuntu2
python-dateutil           2.8.2
python-debian             0.1.43+ubuntu1.1
python-json-logger        2.0.7
python-magic              0.4.24
pytz                      2022.1
PyYAML                    5.4.1
pyzmq                     25.1.1
Quart                     0.14.1
referencing               0.30.2
requests                  2.31.0
rfc3339-validator         0.1.4
rfc3986-validator         0.1.1
rpds-py                   0.12.0
ruamel.yaml               0.18.5
ruamel.yaml.clib          0.2.8
SecretStorage             3.3.1
Send2Trash                1.8.2
service-identity          18.1.0
setuptools                59.6.0
simplejson                3.17.6
six                       1.16.0
sniffio                   1.3.0
sos                       4.5.6
soupsieve                 2.5
SQLAlchemy                2.0.23
ssh-import-id             5.11
stack-data                0.6.3
systemd-python            234
terminado                 0.17.1
tinycss2                  1.2.1
toml                      0.10.2
tomli                     2.0.1
tornado                   6.3.3
traitlets                 5.13.0
ttystatus                 0.38
Twisted                   22.1.0
types-python-dateutil     2.8.19.14
typing_extensions         4.8.0
ubuntu-advantage-tools    8001
ufw                       0.36.1
unattended-upgrades       0.1
uri-template              1.3.0
urllib3                   1.26.5
wadllib                   1.3.6
wcwidth                   0.2.9
webcolors                 1.13
webencodings              0.5.1
websocket-client          1.6.4
Werkzeug                  2.0.2
wheel                     0.37.1
wsproto                   1.0.0
zipp                      1.0.0
zope.interface            5.4.0

I’m probably not using conda environment, so there is no conmmand conda list on my machine.
And by the way, I’m using wsl2 system on my machine.

1 Like

I tried to open URL http://127.0.0.1:8000, but I cannot connect to it:

Unable to connect

Firefox can’t establish a connection to the server at 127.0.0.1:8000.

    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer’s network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the web.
1 Like

Does it work if you use localhost instead of 127.0.0.1?

And by the way, I’m using wsl2 system on my machine.

That’s possibly relevant. I have absolutely no idea how wsl interacts with things like sockets. I thought you said it was running on ubuntu 22.04? In general, JupyterHub doesn’t support Windows, though some users have been able to run it with non-default Authenticators and Spawners.

2 Likes

Using URL localhost:8000 works fine finally. Thank you so so so much! This problem has been bothering me so long.

1 Like