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

how to close running jupyter notebook servers? #2844

Open
yunyundong opened this Issue Sep 16, 2017 · 22 comments

Comments

Projects
None yet
@yunyundong

yunyundong commented Sep 16, 2017

when i type command jupyter notebook list, the outputs are as follows:
http://localhost:8888/?token=a21aae4b484b7087c91f5d161c1fd595a76f05b0fc2204c8 :: C:\06Codes_From_Jupyter
http://localhost:8888/?token=3e6a9a390cc121315ccb7565c287ef6ed6bddd6ec66c9ed2 :: C:\06Codes_From_Jupyter
http://localhost:8888/?token=d53af56195ba09b1156ea7a42e86ff574c8a8ee44731db5b :: C:\06Codes_From_Jupyter
http://localhost:8889/?token=1f1250e4cdf841e6162591fce9c16769266b21f3e152a42c :: C:\06Codes_From_Jupyter

In fact, when i paste http://localhost:8888/?token=a21aae4b484b7087c91f5d161c1fd595a76f05b0fc2204c8 into the chrome broswer, i fail to open the address.
but I don't know how to close the runing servers?
Beside,when i start the jupyter notebook app, the new created servering, whose port are still 8888.Then I start the other jupyter notebook app, its port are 8889.
so, I don't know what there happen?

@takluyver

This comment has been minimized.

Member

takluyver commented Sep 16, 2017

Each server should start on a new port. jupyter notebook list is reading a set of data files - each notebook server you run writes a file when it starts up, and attempts to remove it when it shuts down. If you see different listed servers on the same port, that means some of them exited without being able to remove the file they made.

If you launch the notebook from a command prompt, you can shut it down by pressing Ctrl-C in that same command prompt. If not, you can run jupyter notebook stop 8888.

@kannankumar

This comment has been minimized.

kannankumar commented Oct 28, 2017

I get an Access Denied error when running jupyter notebook stop 8888 on Win10.

    os.kill(server['pid'], signal.SIGTERM)
PermissionError: [WinError 5] Access is denied

Tried running jupyter notebook stop 8888 in Administrator mode, still got the error.
Any suggestions on how I can stop the running notebook servers on Win10? (Other than a system restart)

@takluyver

This comment has been minimized.

Member

takluyver commented Oct 31, 2017

If you still have the command prompt where you started them, try Ctrl-C or Ctrl-Break. If not, it's possible by making an HTTP post request to /api/shutdown. We know that's not ideal, we do plan to have a better way.

@takluyver

This comment has been minimized.

Member

takluyver commented Oct 31, 2017

Pull request #3000 should fix jupyter notebook stop on Windows.

@gnestor

This comment has been minimized.

Contributor

gnestor commented Oct 31, 2017

I just submitted a PR that introduces a new server option that will add a "shutdown" button next to the "logout" button: #3004

@Sledge-

This comment has been minimized.

Sledge- commented Feb 22, 2018

In windows you can also just kill from task manager.

@JamesCarter1

This comment has been minimized.

JamesCarter1 commented Feb 28, 2018

Hello,
I'm kind of facing to the same issue.
I have all those servers opened (Maybe it's not the right work, I'm beginner) :

http://localhost:8890/?token=4322ab537d86c86a206e6a63c05137fc9c388dd2d425890e :: C:\Users\test
http://localhost:8888/?token=7d7bd406465f34b5d491432bd7e231f980463ba5fb3bb1d6 :: C:\Users\test
http://localhost:8890/?token=dd8df31466fee972a9dec340c9792cf73eaddab14d280b31 :: C:\Users\test
http://localhost:8889/?token=7afae4454280bed0ccdd786c635d59f1002050475b5ea76a :: C:\Users\test

Everytime I try to shut them down with thi following command :
jupyter notebook stop 8888
I get this error.

Shutting down server on port 8888 ...
Traceback (most recent call last):
  File "C:\Users\test\Anaconda3\Scripts\jupyter-notebook-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\test\Anaconda3\lib\site-packages\jupyter_core\application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\Users\test\Anaconda3\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
    app.start()
  File "C:\Users\test\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 1571, in start
    super(NotebookApp, self).start()
  File "C:\Users\test\Anaconda3\lib\site-packages\jupyter_core\application.py", line 255, in start
    self.subapp.start()
  File "C:\Users\test\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 451, in start
    if not self.shutdown_server(server):
  File "C:\Users\test\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 442, in shutdown_server
    return shutdown_server(server, log=self.log)
  File "C:\Users\test\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 402, in shutdown_server
    HTTPClient().fetch(req)
  File "C:\Users\test\Anaconda3\lib\site-packages\tornado\httpclient.py", line 102, in fetch
    self._async_client.fetch, request, **kwargs))
  File "C:\Users\test\Anaconda3\lib\site-packages\tornado\ioloop.py", line 458, in run_sync
    return future_cell[0].result()
  File "C:\Users\test\Anaconda3\lib\site-packages\tornado\concurrent.py", line 238, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 4, in raise_exc_info
ConnectionRefusedError: [Errno 10061] Unknown error

I dont know what to do, I tried to find the task on the task manager but i couldnt.
Thank you by advance

@takluyver

This comment has been minimized.

Member

takluyver commented Mar 1, 2018

That might happen if those servers have crashed, so they're not running but the info file that records them hasn't been cleaned up.

Try restarting the computer and running jupyter notebook list again. If there are still servers there, you can remove the files from the runtime directory (run jupyter --paths to see where that is on your system).

@JamesCarter1

This comment has been minimized.

JamesCarter1 commented Mar 1, 2018

Hello !
It perfectly worked !!! That's exactly what I needed , the path of the runtime files. I couldnt find it...

So i cleared the runtime directory and now I can shutdown the servers with any issue.
Thank you so much

@markbessen

This comment has been minimized.

markbessen commented Mar 7, 2018

Hello,
When I run jupyter notebook list, I get this:

http://localhost:8889/?token=blah :: /Users/me/storyfit/data-mining/research
http://localhost:8891/?token=blah2 :: /Users/me/storyfit/data-mining
http://localhost:8890/?token=blah23 :: /Users/me/storyfit/data-mining/research
http://localhost:8888/?token=blah54 :: /Users/me/storyfit/data-mining/research

(I've anonymized the tokens.)

I thought I should be able to kill these notebook servers using jupyter notebook stop 8888, but when I try that, I get the following:

Shutting down server on port 8888 ...
Traceback (most recent call last):
  File "/Users/Mark/anaconda3/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/Users/Mark/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/Users/Mark/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 596, in launch_instance
    app.start()
  File "/Users/Mark/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 1571, in start
    super(NotebookApp, self).start()
  File "/Users/Mark/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 255, in start
    self.subapp.start()
  File "/Users/Mark/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 451, in start
    if not self.shutdown_server(server):
  File "/Users/Mark/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 442, in shutdown_server
    return shutdown_server(server, log=self.log)
  File "/Users/Mark/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 402, in shutdown_server
    HTTPClient().fetch(req)
  File "/Users/Mark/anaconda3/lib/python3.5/site-packages/tornado/httpclient.py", line 102, in fetch
    self._async_client.fetch, request, **kwargs))
  File "/Users/Mark/anaconda3/lib/python3.5/site-packages/tornado/ioloop.py", line 453, in run_sync
    return future_cell[0].result()
  File "/Users/Mark/anaconda3/lib/python3.5/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
tornado.httpclient.HTTPError: HTTP 404: Not Found

This seems to be very related to the questions above, but I'm struggling to figure out why I'm not able to stop the notebook servers. Any help much appreciated!!! Thanks

@markbessen

This comment has been minimized.

markbessen commented Mar 7, 2018

For what it's worth, when I try to go to those pages in Chrome, I can't access the notebooks in browser:

image

@takluyver

This comment has been minimized.

Member

takluyver commented Mar 7, 2018

The entries in the list can be left there erroneously if the server has exited without being able to clear up its files. Though in that case you should get a connection error instead of a 404.

If you think that's what's happened, and the servers are no longer running, you can clean up the files in the runtime directory (use jupyter --paths to see where that is).

@jmagosta

This comment has been minimized.

jmagosta commented Mar 23, 2018

$ jupyter notebook stop 8888

Gives this error:

[C 02:02:07.518 NotebookApp] No such file or directory: /home/tox/stop

This is ubuntu 16.04

tox@lrndsvm:$ jupyter notebook --version
5.0.0
tox@lrndsvm:$ jupyter --version
4.3.0
tox@lrndsvm:~$

@takluyver

This comment has been minimized.

Member

takluyver commented Mar 23, 2018

Try updating the notebook package to a newer version. I think stop was added since 5.0.

@ShusenTang

This comment has been minimized.

ShusenTang commented May 2, 2018

This might help:
first, run jupyter notebook list to get jupyter used port-number.
then,run lsof -n -i4TCP:[port-number]to get PID, The PID is the second field in the output.
finally, run kill -9 [PID]to kill this process.

@gnestor

This comment has been minimized.

Contributor

gnestor commented May 2, 2018

In the next release (5.5), there will be an option to display a "Quit" button in the dashboard, allowing users without terminal/SSH access to stop a notebook server (#3004).

@takluyver

This comment has been minimized.

Member

takluyver commented May 2, 2018

(And this option is on by default)

nilqed added a commit to nilqed/spad_http that referenced this issue May 11, 2018

Changes:
* .spad to .input
* algbera=false => charybdis/algebra not printed
* shutdown jupyter nb server ?? jupyter/notebook#2844
  -- do_shutdown
* do_complete (partially)
* Capture: stdout/stderr :: eval, json
* New: Error handling
@fapertuzu

This comment has been minimized.

fapertuzu commented May 20, 2018

Have you tried by executing the command prompt as admin?

@EndCho

This comment has been minimized.

EndCho commented Aug 28, 2018

Our jupyter runing pyspark code had no answer, it is so so so slowly just run print(1+2),there is no result in 4 hours。How can i restart the jupyter on server?
We can run code in cluster use pyspark.

@ArnoutDevos

This comment has been minimized.

ArnoutDevos commented Oct 10, 2018

The way I solved it:

  1. Check where your runtime folder is located:
    jupyter --paths
  2. Remove all files in the runtime folder:
    rm -r [path to runtime folder]/*
  3. Check with top if there are any jupyter notebook running processes left, and if so kill their PID.
    top | grep jupyter &
    kill [PID]
  4. Then relaunch your notebook on the desired ip and port:
    jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root &
@ZhangHan

This comment has been minimized.

ZhangHan commented Oct 19, 2018

Does jupyter notebook stop support stopping a Jupyter notebook configured with SSL?
I launched my jupyter notebook in SSL mode by providing a key and perm file. But when I used jupyter notebook stop $PORT to stop jupyter, I got the following:

Shutting down server on port 8443 ...
[W 01:55:02.120 NotebookApp] SSL Error on 11 ('127.0.0.1', 8443): [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)
Traceback (most recent call last):
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/jupyter_core/application.py", line 266,in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/notebook/notebookapp.py", line 1671, instart
    super(NotebookApp, self).start()
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/jupyter_core/application.py", line 255,in start
    self.subapp.start()
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/notebook/notebookapp.py", line 460, in start
    if not self.shutdown_server(server):
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/notebook/notebookapp.py", line 451, in shutdown_server
    return shutdown_server(server, log=self.log)
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/notebook/notebookapp.py", line 411, in shutdown_server
    HTTPClient().fetch(req)
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/httpclient.py", line 119, in fetch
    self._async_client.fetch, request, **kwargs))
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/ioloop.py", line 576, in run_sync
    return future_cell[0].result()
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/simple_httpclient.py", line 272, in run
    max_buffer_size=self.max_buffer_size)
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/tcpclient.py", line 242, in connect
    server_hostname=host)
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tornado/iostream.py", line 1501, in _do_ssl_handshake
    self.socket.do_handshake()
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)

I think it's because it's trying to access localhost with http instead of https. Is there a way to configure it to use https?

@Haager

This comment has been minimized.

Haager commented Nov 7, 2018

This might help:
first, run jupyter notebook list to get jupyter used port-number.
then,run lsof -n -i4TCP:[port-number]to get PID, The PID is the second field in the output.
finally, run kill -9 [PID]to kill this process.

It worked for me, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment