Getting error while using jupyterhub + Nginx reverse proxy

Hi All,

I’m encountering an issue while configuring JupyterHub with Nginx as a reverse proxy. I am receiving the following error:

[W 2024-09-04 15:28:50.914 JupyterHub proxy:944] api_request to the proxy failed with status code 599, retrying...
[E 2024-09-04 15:28:50.914 JupyterHub app:3873]
    Traceback (most recent call last):
      File "D:\Simsight\envs\labenv\lib\site-packages\jupyterhub\app.py", line 3871, in launch_instance_async
        await self.start()
      File "D:\Simsight\envs\labenv\lib\site-packages\jupyterhub\app.py", line 3658, in start
        await self.proxy.get_all_routes()
      File "D:\Simsight\envs\labenv\lib\site-packages\jupyterhub\proxy.py", line 989, in get_all_routes
        resp = await self.api_request('', client=client)
      File "D:\Simsight\envs\labenv\lib\site-packages\jupyterhub\proxy.py", line 953, in api_request
        result = await exponential_backoff(
      File "D:\Simsight\envs\labenv\lib\site-packages\jupyterhub\utils.py", line 265, in exponential_backoff
        raise asyncio.TimeoutError(fail_message)
    asyncio.exceptions.TimeoutError: Repeated api_request to proxy path "" failed.

Here is the JupyterHub configuration I have modified:

c.ConfigurableHTTPProxy.api_url = ''
c.ConfigurableHTTPProxy.should_start = False
c.ConfigurableHTTPProxy.auth_token='3cc4cbad548f6775d776ee4371e1db1ba0c55a3e2eb702e51040923b467c3f9b'
c.JupyterHub.bind_url = 'http://127.0.0.1:8000'
c.JupyterHub.authenticator_class = 'jupyterhub.auth.NullAuthenticator'

I used the Nginx configuration provided at JupyterHub Configuration Guide, and my Nginx is set to listen on port 8082.

Is there something I might have missed in the configuration?

System: Windows 10
JupyterHub Version: 5.1.0

This is probably the key:

Is there a reason you’ve removed the API URL for the proxy? It’s not going to work if the Hub can’t talk to the proxy API.

JupyterHub does not support Windows, though that doesn’t mean you won’t be able to get it to work. It does mean we can’t really help much.

1 Like

Hi Minrk,

Thank you for your reply. I will try the same configuration on a Linux machine and check if the issue persists.

Hi Minrk,
I have tried the same configuration on a CentOS 7 machine but encountered the following error:

W 2024-09-05 15:00:30.051 JupyterHub proxy:944] api_request to the proxy failed with status code 599, retrying...
[E 2024-09-05 15:00:30.052 JupyterHub app:3873]
    Traceback (most recent call last):
      File "/root/mambaenvs/hubenv/lib/python3.9/site-packages/jupyterhub/app.py", line 3871, in launch_instance_async
        await self.start()
      File "/root/mambaenvs/hubenv/lib/python3.9/site-packages/jupyterhub/app.py", line 3658, in start
        await self.proxy.get_all_routes()
      File "/root/mambaenvs/hubenv/lib/python3.9/site-packages/jupyterhub/proxy.py", line 989, in get_all_routes
        resp = await self.api_request('', client=client)
      File "/root/mambaenvs/hubenv/lib/python3.9/site-packages/jupyterhub/proxy.py", line 953, in api_request
        result = await exponential_backoff(
      File "/root/mambaenvs/hubenv/lib/python3.9/site-packages/jupyterhub/utils.py", line 265, in exponential_backoff
        raise asyncio.TimeoutError(fail_message)
    asyncio.exceptions.TimeoutError: Repeated api_request to proxy path "" failed.

Here are the changes I made to the JupyterHub configuration:

c.JupyterHub.bind_url = 'http://127.0.0.1:8000'
c.ConfigurableHTTPProxy.should_start = False
c.JupyterHub.authenticator_class = 'jupyterhub.auth.NullAuthenticator'
c.ConfigurableHTTPProxy.api_url = 'http://127.0.0.1:8082'  # Nginx reverse proxy URL

Nginx is running on port 8082
System: CentOS 7 (CentOS Linux release 7.9.2009).
JupyterHub Version: 5.1.0

Could you please help me resolve this issue?

I have tried leaving c.ConfigurableHTTPProxy.api_url empty (c.ConfigurableHTTPProxy.api_url = '') and also commented out the configuration (#c.ConfigurableHTTPProxy.api_url), but I am still encountering the same error.

api_url must match the --api-url of the proxy, which is 8001 by default, I think. How are you starting the proxy?

Hi Minrk,
I’m using nginx as a reverse proxy.
I start nginx using systemctl

I mean configurable-http-proxy. How are you starting it? You’ve set c.ConfigurableHTTPProxy.should_start = False, which means you are running CHP yourself somewhere else instead of letting JupyterHub start it. How are you launching configurable-http-proxy?

I’d prefer not to use CHP and was exploring the option of using Nginx as a proxy instead.

CHP is not any generic reverse proxy. It is a specific component of JupyterHub that keeps track of routing table of the JupyterHub. So, you cannot swap CHP with nginx.

If you have issues with CHP, there is an alternative traefik proxy which you can use.

1 Like