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

jupyter lab stop 8888 -> HTTP 403: Forbidden (introduced in 1.17.0) #829

Closed
jhgoebbert opened this issue May 3, 2022 · 6 comments
Closed
Labels

Comments

@jhgoebbert
Copy link

jhgoebbert commented May 3, 2022

Description

jupyter lab stop <port> fails with tornado.httpclient.HTTPClientError: HTTP 403: Forbidden

Reproduce

  1. Create a new virtual python environment: python -m venv jlab
  2. Activate it: source ./jlab/bin/activate
  3. Install the current JupyterLab: pip install jupyterlab
  4. Run JupyterLab in the background: (jupyter lab --no-browser ) &
  5. Wait until it is up and running and check which port it uses (probably 8888).
  6. Shut down the JupyterLab with jupyter lab stop <port>

It will fail with

(jlab) [goebbert1@localhost ~]$ jupyter lab stop 8888 --debug
[..]
Shutting down server on 8888...
[JupyterServerStopApp] POST request to http://localhost:8888/api/shutdown
[W 2022-05-03 12:34:22.205 ServerApp] 403 POST / (::1): '_xsrf' argument missing from POST
[W 2022-05-03 12:34:22.206 ServerApp] 403 POST / (::1) 0.50ms referer=None
Traceback (most recent call last):
  File "/home/goebbert1/jlab/bin/jupyter-lab", line 8, in <module>
    sys.exit(main())
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/extension/application.py", line 594, in launch_instance
    serverapp.start()
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/serverapp.py", line 2757, in start
    self.start_app()
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/serverapp.py", line 2655, in start_app
    super().start()
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_core/application.py", line 258, in start
    self.subapp.start()
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/serverapp.py", line 589, in start
    self._shutdown_or_exit(port, server)
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/serverapp.py", line 564, in _shutdown_or_exit
    if not self.shutdown_server(server):
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/serverapp.py", line 560, in shutdown_server
    return shutdown_server(server, log=self.log)
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/serverapp.py", line 507, in shutdown_server
    fetch(url, method="POST", body=b"", headers={"Authorization": "token " + server_info["token"]})
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/utils.py", line 352, in fetch
    response = HTTPClient(AsyncHTTPClient).fetch(request)
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/tornado/httpclient.py", line 134, in fetch
    response = self._io_loop.run_sync(
  File "/home/goebbert1/jlab/lib64/python3.9/site-packages/tornado/ioloop.py", line 530, in run_sync
    return future_cell[0].result()
tornado.httpclient.HTTPClientError: HTTP 403: Forbidden

Expected behavior

JupyterLab cleanly shuts down like it did with jupyter-server 1.16.0:

(jlab) [goebbert1@localhost ~]$ jupyter lab stop 8889 --debug
[JupyterServerStopApp] Searching ['/home/goebbert1', '/home/goebbert1/.jupyter', '/home/goebbert1/jlab/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[JupyterServerStopApp] Looking for jupyter_config in /etc/jupyter
[JupyterServerStopApp] Looking for jupyter_config in /usr/local/etc/jupyter
[JupyterServerStopApp] Looking for jupyter_config in /home/goebbert1/jlab/etc/jupyter
[JupyterServerStopApp] Looking for jupyter_config in /home/goebbert1/.jupyter
[JupyterServerStopApp] Looking for jupyter_config in /home/goebbert1
Shutting down server on 8889...
[JupyterServerStopApp] POST request to http://localhost:8889/api/shutdown
[I 2022-05-03 12:44:45.840 ServerApp] 302 GET / (::1) 0.48ms
[I 2022-05-03 12:44:45.842 LabApp] 302 GET /lab (::1) 0.62ms
[D 2022-05-03 12:44:45.844 ServerApp] Using contents: services/contents
[D 2022-05-03 12:44:45.855 ServerApp] Path favicon.ico served from /home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/static/favicon.ico
[D 2022-05-03 12:44:45.855 ServerApp] Path style/bootstrap.min.css served from /home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/static/style/bootstrap.min.css
[D 2022-05-03 12:44:45.855 ServerApp] Path style/bootstrap-theme.min.css served from /home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/static/style/bootstrap-theme.min.css
[D 2022-05-03 12:44:45.855 ServerApp] Path style/index.css served from /home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/static/style/index.css
[D 2022-05-03 12:44:45.855 ServerApp] Path logo/logo.png served from /home/goebbert1/jlab/lib64/python3.9/site-packages/jupyter_server/static/logo/logo.png
[D 2022-05-03 12:44:45.856 ServerApp] 200 GET /login?next=%2Flab (::1) 12.75ms
[JupyterServerStopApp] SIGTERM to PID 46443
[C 2022-05-03 12:44:50.883 ServerApp] received signal 15, stopping
[I 2022-05-03 12:44:50.883 ServerApp] Shutting down 3 extensions
[D 2022-05-03 12:44:50.883 ServerApp] jupyterlab | extension app "lab" stopping
[D 2022-05-03 12:44:50.883 ServerApp] jupyterlab | extension app "lab" stopped
[D 2022-05-03 12:44:50.883 ServerApp] nbclassic | extension app "notebook" stopping
[D 2022-05-03 12:44:50.883 ServerApp] nbclassic | extension app "notebook" stopped
[I 2022-05-03 12:44:50.884 ServerApp] Shutting down 0 kernels
[I 2022-05-03 12:44:50.884 ServerApp] Shutting down 0 terminals
[JupyterServerStopApp] Server PID 46443 is gone
[2]+  Done                    ( jupyter lab --no-browser --debug )

Context

  • Operating System and version: RockyLinux8
  • Browser and version: no browser
  • Jupyter Server version: 1.17.0
Troubleshoot Output
(jlab) [goebbert1@localhost jlab]$ jupyter troubleshoot
WARNING: You are using pip version 20.2.4; however, version 22.0.4 is available.
You should consider upgrading via the '/home/goebbert1/jlab/bin/python -m pip install --upgrade pip' command.
$PATH:
        /home/goebbert1/jlab/bin
        /home/goebbert1/.local/bin
        /home/goebbert1/bin
        /usr/local/bin
        /usr/bin
        /usr/local/sbin
        /usr/sbin

sys.path:
/home/goebbert1/jlab/bin
/usr/lib64/python39.zip
/usr/lib64/python3.9
/usr/lib64/python3.9/lib-dynload
/home/goebbert1/jlab/lib64/python3.9/site-packages
/home/goebbert1/jlab/lib/python3.9/site-packages

sys.executable:
/home/goebbert1/jlab/bin/python

sys.version:
3.9.6 (default, Nov 9 2021, 13:31:27)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]

platform.platform():
Linux-4.18.0-348.el8.0.2.x86_64-x86_64-with-glibc2.28

which -a jupyter:
/home/goebbert1/jlab/bin/jupyter

pip list:
Package Version
-------------------- -----------
anyio 3.5.0
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
asttokens 2.0.5
attrs 21.4.0
Babel 2.10.1
backcall 0.2.0
beautifulsoup4 4.11.1
bleach 5.0.0
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.0.12
debugpy 1.6.0
decorator 5.1.1
defusedxml 0.7.1
entrypoints 0.4
executing 0.8.3
fastjsonschema 2.15.3
idna 3.3
importlib-metadata 4.11.3
ipykernel 6.13.0
ipython 8.3.0
ipython-genutils 0.2.0
jedi 0.18.1
Jinja2 3.1.2
json5 0.9.6
jsonschema 4.4.0
jupyter-client 7.3.0
jupyter-core 4.10.0
jupyter-server 1.17.0
jupyterlab 3.3.4
jupyterlab-pygments 0.2.2
jupyterlab-server 2.13.0
MarkupSafe 2.1.1
matplotlib-inline 0.1.3
mistune 0.8.4
nbclassic 0.3.7
nbclient 0.6.2
nbconvert 6.5.0
nbformat 5.3.0
nest-asyncio 1.5.5
notebook 6.4.11
notebook-shim 0.1.0
packaging 21.3
pandocfilters 1.5.0
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
pip 20.2.4
prometheus-client 0.14.1
prompt-toolkit 3.0.29
psutil 5.9.0
ptyprocess 0.7.0
pure-eval 0.2.2
pycparser 2.21
Pygments 2.12.0
pyparsing 3.0.8
pyrsistent 0.18.1
python-dateutil 2.8.2
pytz 2022.1
pyzmq 22.3.0
requests 2.27.1
Send2Trash 1.8.0
setuptools 50.3.2
six 1.16.0
sniffio 1.2.0
soupsieve 2.3.2.post1
stack-data 0.2.0
terminado 0.13.3
tinycss2 1.1.1
tornado 6.1
traitlets 5.1.1
urllib3 1.26.9
wcwidth 0.2.5
webencodings 0.5.1
websocket-client 1.3.2
zipp 3.8.0

Command Line Output
(jlab) [goebbert1@localhost jlab]$ (jupyter lab --no-browser --debug) &
[2] 46299
(jlab) [goebbert1@localhost jlab]$ [D 2022-05-03 12:40:24.122 ServerApp] Searching ['/home/goebbert1/jlab', '/home/goebbert1/.jupyter', '/home/goebbert1/jlab/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[D 2022-05-03 12:40:24.122 ServerApp] Looking for jupyter_config in /etc/jupyter
[D 2022-05-03 12:40:24.122 ServerApp] Looking for jupyter_config in /usr/local/etc/jupyter
[D 2022-05-03 12:40:24.122 ServerApp] Looking for jupyter_config in /home/goebbert1/jlab/etc/jupyter
[D 2022-05-03 12:40:24.122 ServerApp] Looking for jupyter_config in /home/goebbert1/.jupyter
[D 2022-05-03 12:40:24.122 ServerApp] Looking for jupyter_config in /home/goebbert1/jlab
[D 2022-05-03 12:40:24.123 ServerApp] Looking for jupyter_server_config in /etc/jupyter
[D 2022-05-03 12:40:24.123 ServerApp] Looking for jupyter_server_config in /usr/local/etc/jupyter
[D 2022-05-03 12:40:24.123 ServerApp] Looking for jupyter_server_config in /home/goebbert1/jlab/etc/jupyter
[D 2022-05-03 12:40:24.123 ServerApp] Looking for jupyter_server_config in /home/goebbert1/.jupyter
[D 2022-05-03 12:40:24.123 ServerApp] Looking for jupyter_server_config in /home/goebbert1/jlab
[D 2022-05-03 12:40:24.124 ServerApp] Paths used for configuration of jupyter_server_config:
        /etc/jupyter/jupyter_server_config.json
[D 2022-05-03 12:40:24.125 ServerApp] Paths used for configuration of jupyter_server_config:
        /usr/local/etc/jupyter/jupyter_server_config.json
[D 2022-05-03 12:40:24.125 ServerApp] Paths used for configuration of jupyter_server_config:
        /home/goebbert1/jlab/etc/jupyter/jupyter_server_config.d/jupyterlab.json
        /home/goebbert1/jlab/etc/jupyter/jupyter_server_config.d/nbclassic.json
        /home/goebbert1/jlab/etc/jupyter/jupyter_server_config.d/notebook_shim.json
        /home/goebbert1/jlab/etc/jupyter/jupyter_server_config.json
[D 2022-05-03 12:40:24.125 ServerApp] Paths used for configuration of jupyter_server_config:
        /home/goebbert1/.jupyter/jupyter_server_config.json
[D 2022-05-03 12:40:24.126 ServerApp] Paths used for configuration of jupyter_server_config:
        /home/goebbert1/jlab/jupyter_server_config.json
[D 2022-05-03 12:40:24.144 LabApp] Config changed: {'NotebookApp': {}, 'ServerApp': {'open_browser': False, 'log_level': 'DEBUG', 'jpserver_extensions': }, 'ExtensionApp': {'open_browser': False, 'log_level': 'DEBUG'}}
[I 2022-05-03 12:40:24.145 ServerApp] jupyterlab | extension was successfully linked.
[D 2022-05-03 12:40:24.152 NotebookApp] Config changed: {'NotebookApp': {}, 'ServerApp': {'open_browser': False, 'log_level': 'DEBUG', 'jpserver_extensions': }, 'ExtensionApp': {'open_browser': False, 'log_level': 'DEBUG'}}
[I 2022-05-03 12:40:24.152 ServerApp] nbclassic | extension was successfully linked.
[D 2022-05-03 12:40:24.314 ServerApp] Paths used for configuration of jupyter_notebook_config:
        /home/goebbert1/.jupyter/jupyter_notebook_config.json
[D 2022-05-03 12:40:24.314 ServerApp] Paths used for configuration of jupyter_notebook_config:
        /etc/jupyter/jupyter_notebook_config.json
[D 2022-05-03 12:40:24.315 ServerApp] Paths used for configuration of jupyter_notebook_config:
        /usr/local/etc/jupyter/jupyter_notebook_config.json
[D 2022-05-03 12:40:24.315 ServerApp] Paths used for configuration of jupyter_notebook_config:
        /home/goebbert1/jlab/etc/jupyter/jupyter_notebook_config.d/jupyterlab.json
        /home/goebbert1/jlab/etc/jupyter/jupyter_notebook_config.json
[D 2022-05-03 12:40:24.316 ServerApp] Paths used for configuration of jupyter_notebook_config:
        /home/goebbert1/.jupyter/jupyter_notebook_config.json
[I 2022-05-03 12:40:24.316 ServerApp] notebook_shim | extension was successfully linked.
[D 2022-05-03 12:40:24.317 ServerApp] Config changed: {'ExtensionApp': {'open_browser': False, 'log_level': 'DEBUG'}, 'NotebookApp': {}, 'ServerApp': {'open_browser': False, 'log_level': 'DEBUG', 'jpserver_extensions': }}
[D 2022-05-03 12:40:24.317 ServerApp] Raising open file limit: soft 1024->4096; hard 262144->262144
[I 2022-05-03 12:40:24.341 ServerApp] notebook_shim | extension was successfully loaded.
[I 2022-05-03 12:40:24.342 LabApp] JupyterLab extension loaded from /home/goebbert1/jlab/lib64/python3.9/site-packages/jupyterlab
[I 2022-05-03 12:40:24.342 LabApp] JupyterLab application directory is /home/goebbert1/jlab/share/jupyter/lab
[I 2022-05-03 12:40:24.347 ServerApp] jupyterlab | extension was successfully loaded.
[I 2022-05-03 12:40:24.350 ServerApp] nbclassic | extension was successfully loaded.
[I 2022-05-03 12:40:24.351 ServerApp] The port 8888 is already in use, trying another port.
[I 2022-05-03 12:40:24.351 ServerApp] Serving notebooks from local directory: /home/goebbert1/jlab
[I 2022-05-03 12:40:24.351 ServerApp] Jupyter Server 1.17.0 is running at:
[I 2022-05-03 12:40:24.351 ServerApp] http://localhost:8889/lab?token=572392a7c877ca77f16644b42a9311d3f0d0e30e9c7eb88d
[I 2022-05-03 12:40:24.351 ServerApp]  or http://127.0.0.1:8889/lab?token=572392a7c877ca77f16644b42a9311d3f0d0e30e9c7eb88d
[I 2022-05-03 12:40:24.351 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2022-05-03 12:40:24.354 ServerApp]
To access the server, open this file in a browser:
    file:///home/goebbert1/.local/share/jupyter/runtime/jpserver-46299-open.html
Or copy and paste one of these URLs:
    http://localhost:8889/lab?token=572392a7c877ca77f16644b42a9311d3f0d0e30e9c7eb88d
 or http://127.0.0.1:8889/lab?token=572392a7c877ca77f16644b42a9311d3f0d0e30e9c7eb88d
@jhgoebbert jhgoebbert added the bug label May 3, 2022
@welcome
Copy link

welcome bot commented May 3, 2022

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! 🎉

@jhgoebbert jhgoebbert changed the title jupyter lab stop 8888 -> HTTP 403: Forbidden jupyter lab stop 8888 -> HTTP 403: Forbidden (introduced in 1.17.0) May 3, 2022
@minrk
Copy link
Contributor

minrk commented May 4, 2022

Huh, I would think this was fixed by #798, but that's in 1.17.0.

@jhgoebbert
Copy link
Author

Can anyone confirm that jupyter lab stop 8888 fails with errors even with jupyter-server 1.17.0 installed?
I did my tests on two systems inside a python virtual environment. One was a completly new installed VM with RockyLinux8.
Hence, I expect that the bug is not system-specific.

@kevin-bates
Copy link
Member

Can anyone confirm that jupyter lab stop 8888 fails with errors even with jupyter-server 1.17.0 installed?

yes, I can reproduce this using 1.17.0 on a Mac.

@Zsailer
Copy link
Member

Zsailer commented May 6, 2022

Fixed by #836, I believe. @jhgoebbert, can you confirm?

@jhgoebbert
Copy link
Author

Great! Yes, I can confirm that the error no longer occurs in the current branch 1.x. Thanks a lot @Zsailer

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

4 participants