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:
Start jupyter (local shell)
jupyter notebook
In chrome create a new notebook (python 3), which will result in a url like:
http://localhost:8888/notebooks/Untitled1.ipynb?kernel_name=python3
Create and run a single cell in that new notebook:
print(1)
Restart jupyter (Ctrl-C followed by [yes] to the prompt to exit), followed by:
jupyter notebook
Go to the same chrome tab with the same single cell notebook and click OK for the pop-up "Connection failed"
Observe the notebook showing: [Connecting to Kernel] without success.
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
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):
Create it:
$ jupyter notebook --generate-config
Open the autogenerated file in a text editor and find the line:
#c.NotebookApp.use_redirect_file = True
Uncomment that line if it's commented out
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).
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!
Related
I remember I was able to reconnect to an existing Jupyter notebook session in VS code before by changing the kernel for a notebook. Now the option to reconnect to an existing session is gone, see:
How do I reconnect to an existing Jupyter notebook session in VS code?
To be clear, the sessions were never shut down. In fact, I can still see them running in the Running tab of my browser version of jupyter notebook, although clicking on them results in a 404 error:
The jupyter kernel is running on a remote server. I use a SSH session to connect back to it when I work.
Current versions: VS code is v1.68.1 and the Jupyter extension on remote machine is v2022.5.1001601848, if that helps.
If you would like to connect to an existing jupyter server can you do so by going into the command Jupyter: Specify Jupyter Server for Connections and selecting the appropriate remote server from the list. If the required server is not on that list, then you can select it.
When I run
jupyter notebook
in the terminal, jupyter appears to launches correctly, but any attempt to view the page at localhost:8888 in chrome ends with a timeout. It works just fine in Safari, but it looks like notebook is getting malformed request headers from chrome. Does anyone have suggestions for how to fix this problem?
The output from jupyter reads:
[I 17:32:43.538 NotebookApp] [nb_conda_kernels] enabled, 3 kernels found
[I 17:32:43.799 NotebookApp] ✓ nbpresent HTML export ENABLED
[W 17:32:43.799 NotebookApp] ✗ nbpresent PDF export DISABLED: No module named nbbrowserpdf.exporters.pdf
[I 17:32:43.802 NotebookApp] [nb_conda] enabled
[I 17:32:43.846 NotebookApp] [nb_anacondacloud] enabled
[I 17:32:43.852 NotebookApp] Serving notebooks from local directory: /Users/ianriley/Development/kaggle
[I 17:32:43.852 NotebookApp] 0 active kernels
[I 17:32:43.852 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 17:32:43.852 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
However when I navigate to localhost:8888, nothing shows up, and the connection eventually times out. Jupyter then prints the following to console:
[I 17:53:15.524 NotebookApp] Malformed HTTP message from ::1: Malformed HTTP headers: ''
Perhaps the weirdest part of this is that I was able to run jupyter notebook just a couple of days ago, and I've not updated since then, to my knowledge. In case it is helpful, I'm running jupyter 4.2.0 on a macbook pro running sierra, and attempting to view the webpage with chrome v 56.0.2924.87. Thanks in advance for any help. Please let me know if I can supply additional information.
For anyone stumbling across this thread in 2021 like I did I found that Chrome HSTS was responsible for auto forwarding from http to https in my local development environment. I was able to get around this by:
Going to chrome://net-internals/#hsts in my Chrome browser and entering the domain you are having issues with under Delete domain security and clicking on the Delete button.
I had the same issue and managed to get it to load again by resetting my Chrome profile by going to chrome://settings/resetProfileSettings
Prior to this I tried clearing the cache/history but that didn't help, I'm guessing some part of the profile was corrupt.
Two solutions worked for me:
1) Resetting Chrome settings by going to chrome://settings/resetProfileSettings (as suggested by Neil)
2) Accessing the notebook via http instead of https (remove the "s" in http) - I was able to access my notebook this way via Safari, but not Chrome as Chrome defaults to https
Starting an instance of Anaconda navigator helped in my case
Accessing the notebook via http instead of https (remove the "s" in http) - I was able to access my notebook this way via Safari, but not Chrome as Chrome defaults to https
helped to resolve this
I'm using python3.5 and jupyter 4.0.6. I launched the jupyter notebook, and get the following output:
[I 21:47:27.021 NotebookApp] Serving notebooks from local directory: /home/nitrous
[I 21:47:27.021 NotebookApp] 0 active kernels
[I 21:47:27.021 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 21:47:27.022 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 21:47:27.023 NotebookApp] No web browser found: could not locate runnable browser.
on my firefox browser, I typed the specified localhost url: http://localhost:8888/ but I get unable to connect error message. What am I missing? is the hint of the problem on this line:
[W 21:47:27.023 NotebookApp] No web browser found: could not locate runnable browser.
it is my first time using the notebook. I tried to put the below code in the jupyter_notebook_config.py file but to no avail:
c.NotebookApp.open_browser = True
c.NotebookApp.browser = 'firefox'
it also says 0 active kernels. is that a problem?
If you are running your jupyter notebook in a VM (mostly on a linux vm on a windows guest) and trying to access from guest, you will need to launch Jupyter Notebook with right options. Please try to run it like below and it should work.
jupyter notebook --ip=0.0.0.0 --no-browser
Please check the ip of the VM before you enter the URL in firefox. you can use
ifconfig
command for this.
While running Jupyter on my ec2 instance I had faced the same issue.
I resolved it by executing the following command :
jupyter notebook --no-browser
Initially it will show 0 active kernels, once we start creating notebooks on different environments like Python,R etc it will show us the number of active kernels.
I had a similar problem but with Chrome. I dont know in firefox but in chrome, Settings-> Enable guest browsing.
I have a similar problem at first. I solve it by changing the following line in jupyter_notebook_config.py:
c.NotebookApp.browser = r"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe --app=%s"
I guess adding prefix "r" prefix to convert the string to raw string has actually solved this problem.
I have launched an AWS EMR cluster following the steps on the EMR page. After connecting through SSH (putty in Windows 7) and enabling foxyproxy (Chrome), it launched fine and can be accessed in my laptop browser.
Pyspark and sparkR come with the EMR Spark 1.6.0 installation and work perfectly in the terminal.
The ports for Hue etc. work fine in the following format:
ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com:/
I installed Jupyter by following the steps on http://jupyter.readthedocs.org/en/latest/install.html#using-pip
sudo pip install jupyter
I opened a new notebook with
jupyter notebook
It opened a browser in the terminal that I shut down. It gave the following output:
[I 14:32:12.001 NotebookApp] Writing notebook server cookie secret to /home/hadoop/.local/share/jupyter/runtime/notebook_cookie_secret
[I 14:32:12.033 NotebookApp] The port 8888 is already in use, trying another random port.
[I 14:32:12.037 NotebookApp] Serving notebooks from local directory: /home/hadoop
[I 14:32:12.037 NotebookApp] 0 active kernels
[I 14:32:12.038 NotebookApp] The Jupyter Notebook is running at: http://localhost:8889/
[I 14:32:12.038 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
I tried accessing it in my browser by:
localhost:8889/
(didn't work of course)
then by:
ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com:8889/
(replacing the x's), but this gave an error as well.
This webpage is not available
ERR_CONNECTION_RESET
So how can I access Jupyter in my local browser when it has been installed on the head node of an EMR cluster?
I haven't actually used Jupyter yet, but I tried installing and running it like you did, and I noticed that Jupyter is configured by default to listen only on localhost, which is why you can't access it from your browser.
I then found that running "jupyter notebook --generate-config" would generate a config file ~/.jupyter/jupyter_notebook_config.py, which you can edit in order to make it listen on 0.0.0.0 instead of localhost. Just change c.NotebookApp.ip to '0.0.0.0' and uncomment the line.
After doing this, I was able to access Jupyter from my browser using a URL like http://ip-10-168-157-117.ec2.internal:8888/. (Mine is listening on port 8888 by default, but I'm assuming yours started on port 8889 due to having Hue installed and listening on port 8888 already.)
I've been trying to get ipython/jupyter notebook running as a notebook server on Google Compute Engine (Ubuntu 14.04 VM), but can't connect to the Python kernel.
I started with the latest Anaconda distribution. I can connect to the notebook server from my local machine via the web, browse the directory tree of the VM, and create new notebook, but never connects to the kernel (orange message in the upper right of Jupyter). The notebook port (8888) is open in the firewall settings. iPython notebook returns the following:
[I 19:21:10.152 NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
[I 19:21:10.169 NotebookApp] Serving notebooks from local directory: /home/rattlerray
[I 19:21:10.170 NotebookApp] 0 active kernels
[I 19:21:10.170 NotebookApp] The IPython Notebook is running at: https://[all ip addresses on your system]:8888/
[I 19:21:10.170 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 19:22:13.835 NotebookApp] 302 GET / (98.169.96.157) 0.85ms
[I 19:22:31.902 NotebookApp] Creating new notebook in
[I 19:22:33.634 NotebookApp] Kernel started: 011d8a15-0e4a-448a-b02a-4121780e4bb6
If anyone has run into this before and can offer some things to check, I'd appreciate it. Googling around hasn't helped and I'd really like to get this working on the cloud. Thanks!
I am using EC2 but encounter same problem.
I uses SSL told in the tutorial, after login and open a notebook in Safari always showing "Connecting to kernel". Then I try Chrome, which gives warning about certificate but works fine.
Then I comment the certificate in config file, then open in Safari it works fine.
If you are using Firefox, may be this issue Unable to contact kernel in Firefox after updating to ipython 3.0
Hope this will help.
Update:
The issue is reported on Github: https://github.com/ipython/ipython/issues/8621. As said in the post, this is the limitation of Safari. If you still want to use SSL to visit Notebook, you have to add the certificate into your keychain and trust it. Check the help posted by Apple: https://support.apple.com/kb/PH18677?locale=en_US
Another way you can connect to your IPython (Jupyter) Notebook server is by opening an SSH tunnel with port forwarding. I wrote a how-to post describing my own workflow. I'm using Google Compute Engine from within Chrome but many of the steps are analogous to other setup variations:
https://stharrold.github.io/20151208-ipynb-on-gce-from-chrome.html
Excerpt:
"""
Brief setup routine:
* Start [your] virtual machine instance.
* Start a Jupyter Notebook server on the instance:
$ jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser &
$ disown 1234 (where 1234 is the process ID)
* Create an SSH tunnel to forward a local port to the server's port on the instance:
$ ssh -f -N -L localhost:8888:0.0.0.0:8888 samuel_harrold#123.123.123.123
For [the] Chrome [app] Secure Shell, omit -f to keep the tunnel open (see screenshot [in post]).
* View the server at http://localhost:8888
"""
Additional details are in the post.