Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot stop Jupyter Notebook [closed]

I'm running Jupyter Notebook on a remote machine where I have a password-protected account. If I run:

jupyter-notebook list

i'm told that a jupyter notebook is running at localhost:p, where p is the port. In my case, p=8890. This is fine. However, when I run:

jupyter-notebook stop 8890

I get the following errors:

Shutting down server on port 8890 ...
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 1571, in start
    super(NotebookApp, self).start()
  File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 255, in start
    self.subapp.start()
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 451, in start
    if not self.shutdown_server(server):
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 442, in shutdown_server
    return shutdown_server(server, log=self.log)
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 402, in shutdown_server
    HTTPClient().fetch(req)
  File "/usr/local/lib/python2.7/dist-packages/tornado/httpclient.py", line 102, in fetch
    self._async_client.fetch, request, **kwargs))
  File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 458, in run_sync
    return future_cell[0].result()
  File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 238, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
tornado.httpclient.HTTPError: HTTP 403: Forbidden

I know that I could stop the notebook by killing the corresponding process using kill -9, but that's not really the solution I'm looking for. Any ideas on what could cause this issue?

EDIT: As requested by @Ereli, I report the output of netstat -apn | grep 8890 (unfortunately I don't have super user rights on the machine, so the sudo part is missing)

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:8890          0.0.0.0:*               LISTEN      169484/python   
tcp6       0      0 ::1:8890                :::*                    LISTEN      169484/python   
tcp6       0      0 ::1:50356               ::1:8890                ESTABLISHED -               
tcp6       0      0 ::1:50350               ::1:8890                ESTABLISHED -               
tcp6       0      0 ::1:8890                ::1:50356               ESTABLISHED 169484/python   
tcp6       0      0 ::1:8890                ::1:50350               ESTABLISHED 169484/python   
unix  2      [ ACC ]     STREAM     LISTENING     188903661 -                   /tmp/.java_pid153259.tmp
unix  2      [ ACC ]     STREAM     LISTENING     188904811 -                   /tmp/.java_pid153255.tmp
unix  2      [ ACC ]     STREAM     LISTENING     188906806 -                   /tmp/.java_pid153264.tmp
unix  2      [ ACC ]     STREAM     LISTENING     188904830 -                   /tmp/.java_pid153261.tmp
unix  2      [ ]         STREAM     CONNECTED     188902981 -                   
unix  2      [ ]         STREAM     CONNECTED     188906810 -                   
unix  2      [ ]         STREAM     CONNECTED     188904833 -  
like image 997
Francesco Cariaggi Avatar asked Jan 03 '23 06:01

Francesco Cariaggi


1 Answers

Try pkill which combines ps aux|grep processName and kill.

pkill jupyter

should do the job. if it doesn't work, use

pkill -9 jupyter

if you want limit kill only process you own, try using the -u flag.

 pkill -u `id -u` jupyter

if you need to, kill configurable-http-proxy as that might be the file. running.

This issue seems to be open with jupyterhub team, so I assume it hasn't been fixed.

like image 148
Ereli Avatar answered Jan 05 '23 04:01

Ereli