2

I start with a working jupyter setup, and everything works just fine. I can interrupt or restart the kernel from the notebook without any problems.

If, however, I change some jupyter configuration, or install some modules, and restart jupyter server - I have to wait for about 5 minutes for the open notebooks to recover access to the python kernel.

To reproduce the problem:

  1. Start jupyter (local shell)

    jupyter notebook

  2. In chrome create a new notebook (python 3), which will result in a url like:

    http://localhost:8888/notebooks/Untitled1.ipynb?kernel_name=python3

  3. Create and run a single cell in that new notebook:

    print(1)

  4. Restart jupyter (Ctrl-C followed by [yes] to the prompt to exit), followed by:

    jupyter notebook

  5. Go to the same chrome tab with the same single cell notebook and click OK for the pop-up "Connection failed"

  6. Observe the notebook showing: [Connecting to Kernel] without success.

  7. Try to Restart the kernel via the menu, usually it gets stuck in [Kernel Starting...], and after several manually forced kernel restarts it supposedly succeeds [Kernel Created], but it's a false success, as trying to run the cells gives a [*] busy sign and nothing happens.

After some 5 min of waiting it recovers by itself.

Workarounds:

  • Reloading the notebook in the browser (i.e. hitting Reload at the browser level)
  • Restarting chrome

Software:

  • ubuntu 16.04
  • notebook 5.5.0
  • python 3.6.6
  • chrome 67
  • no adblock software enabled
  • empty ~/.jupyter (removed everything for the sake of the testing, so no extensions or custom configuration)

Same setup works fine in firefox on the same machine.

There are several tickets on github about the same from 2015 (e.g. this, but somehow they blame it on chrome and clearly the issue is still there 3 years later.

Any idea how to solve this?

Thank you.

And here is the log during the open notebook reconnect/restart process:

[I 22:54:09.032 NotebookApp] Kernel restarted: 9aa08efb-74b1-471c-ad0f-bb9dc3577c28 [W 22:54:09.343 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26 [W 22:54:45.348 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26 [W 22:55:37.359 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26 [W 22:57:01.367 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26 [I 22:57:41.337 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28 [W 22:57:41.350 NotebookApp] Replacing stale connection: 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6 [I 22:57:41.351 NotebookApp] Starting buffering for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6 [I 22:57:41.351 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28 [I 22:57:41.352 NotebookApp] Restoring connection for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6 [I 22:57:49.324 NotebookApp] Starting buffering for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6 [I 22:57:49.327 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28 [I 22:57:49.328 NotebookApp] Restoring connection for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6 
2
  • does the url contain "token key"?, it's a security feature that change with each session of jupyter Commented Jul 6, 2018 at 6:43
  • there is no token key, Yasin. I added the exact url to the description of the question, thank you. I tested identical notebooks with different notebook names in firefox and chrome side by side, and only chrome had this issue. Commented Jul 6, 2018 at 6:47

2 Answers 2

2

If you're not using the multi-user environment, the solution is to disable the security feature that prevents the authentication token used to launch the browser from being visible (which can be hijacked by other users on the same computer).

If you don't already have a jupyter notebook config file (usually ~/.jupyter/jupyter_notebook_config.py on linux):

  1. Create it:

    $ jupyter notebook --generate-config

  2. Open the autogenerated file in a text editor and find the line:

    #c.NotebookApp.use_redirect_file = True

  3. Uncomment that line if it's commented out

  4. Replace True with False

If you already have the config file and it doesn't have this setting, simply add to it:

c.NotebookApp.use_redirect_file = False

After changing the config file, you need to restart the jupyter server.

Note that you need jupyter-notebook >= 6.0.3 for this feature to work.

Finally, remember after every jupyter server restart you must reload each notebook for this to work. Only restarting the kernel will not solve this issue (even though it misleadingly says that kernel has been restarted).

Sign up to request clarification or add additional context in comments.

Comments

0

It's a security feature, There's no wrong with chrome, it just auto-reload after 5 minutes because you switch between tabs somehow.

if you open a site when logged in ,all you see is the main site url, (not your password) , the same for the new jupyter notebook , you need a special (random) key works just like a password to get the jupyter server working first place before starting any kernels, and that happen automatically when you fire jupyter and the "main" tab opens, the browser keep the key for any new tab opened (or refreshed )

you are simply logged out when you keep the old-page unrefreshed,

this feature used to protect you from people watching what you send to a public web server

I still don't see any use of your case though (keep the page but restart the server), it's like halting the back-end but expecting the front-end to still function!

1 Comment

When I restart jupyter it automatically opens a new tab in chrome where it resets the security feature you are talking about. So unfortunately this is not it, Yasin. If it were it restarting chrome, or reloading the page, shouldn't have fixed it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.