119

How do you check the login tokens for all running jupyter notebook instances?

Example: you have a notebook running in tmux or screen permanently, and login in remotely through ssh. Sometimes, particularly if you're logging in after a long time, the token is requested again in order to access the notebook session. How do you get hold of the token without having to kill and restart the notebook session with a new token?

5 Answers 5

185

UPDATE

You can now just run jupyter notebook list in the terminal to get the running jupyter sessions with tokens.

enter image description here

Take care that you are within the right environment (conda, virtualenv etc.) otherwise the sessions will list without the associated tokens. Eg: The above reference screenshot is from the conda environment.

Old answer:

Run ipython and enter the following:

> ipython
[1] : system("jupyter" "notebook" "list")
Out[1]: 
['Currently running servers:','http://localhost:8895/token=067470c5ddsadc54153ghfjd817d15b5d5f5341e56b0dsad78a :: /u/user/dir']

If the notebook is running on a remote server, you will have to login in to that server first before running ipython.

7
  • 7
    Why do it in iPython? The system just executes its arguments in a system shell, so you can achieve the same effect just by executing jupyter notebook list in the shell. Commented Apr 11, 2018 at 15:14
  • 1
    You're right, and this is now stated on the jupyter login page Commented Apr 11, 2018 at 15:16
  • 1
    Note that password authentication and token authentication are mutually exclusive, so if Jupyter is running with a password there won't be any token in the jupyter notebook list. Commented Jan 13, 2020 at 20:59
  • 4
    For JUPYTER LAB users: jupyter notebook list lists also all running jupyter lab sessions.
    – zwithouta
    Commented Dec 20, 2020 at 15:58
  • 5
    try jupyter lab list Commented Jan 16, 2021 at 6:27
42

Use this command

$ jupyter server list

It will display the currently running servers for both jupyter lab and jupyter notebook along with the tokens.

3
  • 1
    This should be the accepted answer.
    – a06e
    Commented Nov 20, 2021 at 12:51
  • Thanks. This solved the problem for me.
    – ai2ys
    Commented Jan 18, 2022 at 19:15
  • 1
    This gives me Jupyter command jupyter-server not found. Any recommendations?
    – Mina
    Commented Jun 9, 2022 at 21:21
40

One easy solution (that can save you time by avoiding opening a new terminal) is from the same terminal you are running the notebook to hit (ONLY ONCE!! - cause twice would kill the running server)

Ctrl + C  

By doing that the full link to your notebook will appear (along with the token!) and a prompt asking you to confirm shutting down. Just answer no (n and enter) or do nothing and after 5 seconds the operation will resume. In the meanwhile you would have been able to retrieve the link and/or the token you need.

3
  • 10
    jupyter notebook list doesn't always work for me. This does.
    – Him
    Commented Aug 13, 2019 at 12:56
  • 2
    While the accepted answer is (imo) the "nice and commendable way", this one is more practical as it gives you exactly the desired token.
    – Adrian
    Commented Jun 30, 2020 at 11:56
  • 1
    @Him Did you try jupyter lab list?
    – a06e
    Commented Nov 20, 2021 at 12:51
11

Just right click on the jupyter notebook logo in the currently running server, you probably have a server running already, then click on copy link, then paste the link in a text editor, maybe MS word, you will see the token in the link, copy and paste where token is required. It will work.

1
  • 4
    assumes the notebook can be accessed in a browser, which is not always the case when debugging remote sessions Commented Nov 4, 2019 at 8:39
-8

For running python code in jupyter notebook...we need token id which we can obtain from the terminal by just typing jupyter notebook provided your path has been configured... If not then set your path right first.

Sample

1
  • 4
    this starts a new jupyter session, rather than listing the already running sessions with their tokens Commented Feb 12, 2019 at 14:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.