Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 500 when using Jupyter Server Proxy Arbitrary Ports on a port that is not serving #436

Open
dnoliver opened this issue Nov 20, 2023 · 1 comment
Labels

Comments

@dnoliver
Copy link

dnoliver commented Nov 20, 2023

Bug description

I'm using this extension with The Littlest JupyterHub https://tljh.jupyter.org/en/latest/
I have installed the extension in it using something similar to what is described here https://tljh.jupyter.org/en/latest/howto/admin/enable-extensions.html.
I'm using Arbitrary Port access as described here: https://jupyter-server-proxy.readthedocs.io/en/latest/arbitrary-ports-hosts.html
The extension works fine when there is something serving in the target port.
But if the application is stopped, or if a random port is used as a target, I get an Error 500.

image

Is that error coming from this extension?
Is there any way to set up a default 404 page to have a nicer error?

How to reproduce

  1. Use TLJH
  2. Install this extension
  3. Then, access an arbitrary port that is not serving any application
  4. See error screenshot

Expected behaviour

I should get a 404 page or similar saying that nothing is running on that port

Actual behaviour

I get a 500 error page

Your personal set up

  • OS: Ubuntu 22.04
  • Version(s):

jupyter-admin@ubuntu:~$ jupyter --version
Selected Jupyter core packages...
IPython : 8.17.2
ipykernel : 6.26.0
ipywidgets : 8.1.1
jupyter_client : 8.6.0
jupyter_core : 5.5.0
jupyter_server : 2.10.1
jupyterlab : 4.0.8
nbclient : 0.9.0
nbconvert : 7.11.0
nbformat : 5.9.2
notebook : 7.0.6
qtconsole : not installed
traitlets : 5.13.0

With the latest available TLJH as the Jupyter Hub version

jupyter-admin@ubuntu:~$ jupyterhub --version
4.0.2

I guess the log says that this is coming from the extension :)

# paste relevant logs here, if any
Nov 20 22:35:57 ubuntu jupyterhub-singleuser[21714]: [I 2023-11-20 22:35:57.813 ServerApp] 200 GET /user/admin/api/metrics/v1?1700519757774 (admin@172.24.224.1) 5.85ms
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]: [E 2023-11-20 22:36:00.461 ServerApp] Uncaught exception GET /user/admin/proxy/9999/?redirects=1 (172.24.224.1)
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:     HTTPServerRequest(protocol='http', host='172.24.224.106', method='GET', uri='/user/admin/proxy/9999/?redirects=1', version='HTTP/1.1', remote_ip='172.24.224.1')
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:     Traceback (most recent call last):
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       File "/opt/tljh/user/lib/python3.10/site-packages/tornado/web.py", line 1786, in _execute
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:         result = await result
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       File "/opt/tljh/user/lib/python3.10/site-packages/jupyter_server_proxy/websocket.py", line 111, in get
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:         return await self.http_get(*args, **kwargs)
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       File "/opt/tljh/user/lib/python3.10/site-packages/jupyter_server_proxy/handlers.py", line 554, in http_get
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:         return await self.proxy(port, proxied_path)
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       File "/opt/tljh/user/lib/python3.10/site-packages/jupyter_server_proxy/handlers.py", line 354, in proxy
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:         response = await client.fetch(req, raise_error=False)
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:     ConnectionRefusedError: [Errno 111] Connection refused
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]: [E 2023-11-20 22:36:00.462 ServerApp] {
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "Host": "172.24.224.106",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "Accept-Encoding": "gzip, deflate",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "Accept-Language": "en-US,en;q=0.9",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "Cache-Control": "max-age=0",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "Cookie": "_xsrf=[secret]; jupyterhub-user-admin=[secret]; jupyterhub-session-id=[secret]; _ga=[secret]; _gid=[secret]; access-token-unsecure-Fn0l6JS6x7n2lMwmvFKTJbrpxwB3fmz7yz-shlQ9CYI=[secret]; access-token-unsecure-jOwhHUkOC3-9auZnRfYfGGIIhzyyHd_OSbVNOcZgLnk=[secret]; access-token-unsecure-JJqraO6yYAbaBKprlRSMpQeSXLZpcJSP2C01eFQcnIg=[secret]; access-token-unsecure-j2YSooBRR0OvMKcAOsemA0dWzVzKTaOlEfZBNeoRP8s=[secret]; access-token-unsecure-fCjQv4gkdXTeA8oa6vVsnYBEYuOC_VwmoJDogHExXNQ=[secret]; access-token-unsecure-hvv8hXk9tzcTaD9_bitZg_37hGIcBu6KuLEUUBU6SnU=[secret]; access-token-unsecure-AWKFAquT_9BQGXi7UZpiqzfNH6Na2Nh253tUX57_0Ac=[secret]; access-token-unsecure-z010dEQQ2BDo2qQyyUjh2s3nHbya4Q8U4YZ0iQQolas=[secret]; _ga_R1FN4KJKJH=[secret]",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "Upgrade-Insecure-Requests": "1",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "X-Forwarded-For": "172.24.224.1",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "X-Forwarded-Host": "172.24.224.106",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "X-Forwarded-Port": "80",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "X-Forwarded-Proto": "http",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "X-Forwarded-Server": "ubuntu",
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:       "X-Real-Ip": "172.24.224.1"
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]:     }
Nov 20 22:36:00 ubuntu jupyterhub-singleuser[21714]: [E 2023-11-20 22:36:00.462 ServerApp] 500 GET /user/admin/proxy/9999/?redirects=1 (admin@172.24.224.1) 2.18ms
Nov 20 22:36:03 ubuntu jupyterhub-singleuser[21714]: [I 2023-11-20 22:36:03.517 ServerApp] 200 GET /user/admin/api/metrics/v1?1700519763466 (admin@172.24.224.1) 7.84ms
Full environment
# paste output of `pip freeze` or `conda list` here
Configuration
# jupyterhub_config.py
Logs
@dnoliver dnoliver added the bug label Nov 20, 2023
Copy link

welcome bot commented Nov 20, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant