31593

Jupyter notebook keeps reconnecting to kernel

I get to open the Jupyter console without any problems, but when I create a new notebook it keeps connecting to and disconnecting from the kernel (the messages "Connecting to Kernel" / "Connected" keep showing in the upper right corner). This is what Chrome's console spits out (it's the same in Firefox):

Untitled3.ipynb?kernel_name=python3:121 loaded custom.js default.js:48Default extension for cell metadata editing loaded. rawcell.js:82Raw Cell Format toolbar preset loaded. slideshow.js:43Slideshow extension for metadata editing loaded. menubar.js:240actions jupyter-notebook:find-and-replace does not exist, still binding it in case it will be defined later... MenuBar.bind_events @ menubar.js:240 extension.js Failed to load resource: the server responded with a status of 404 (Not Found) main.js:184Widgets are not available. Please install widgetsnbextension or ipywidgets 4.0 (anonymous) @ main.js:184 session.js:54Session: kernel_created (1b236a4b-902d-4b33-9118-63013be4f270) kernel.js:456Starting WebSockets: ws://[myipaddress]:[myport]/api/kernels/682dc980-d7c6-41e0-b984-14ceb7f8e50c kernel.js:101Kernel: kernel_connected (682dc980-d7c6-41e0-b984-14ceb7f8e50c) kernel.js:101Kernel: kernel_disconnected (682dc980-d7c6-41e0-b984-14ceb7f8e50c) kernel.js:559Connection lost, reconnecting in 1 seconds. kernel.js:101Kernel: kernel_reconnecting (682dc980-d7c6-41e0-b984-14ceb7f8e50c) kernel.js:456Starting WebSockets: ws://[myipaddress]:[myport]/api/kernels/682dc980-d7c6-41e0-b984-14ceb7f8e50c kernel.js:101Kernel: kernel_connected (682dc980-d7c6-41e0-b984-14ceb7f8e50c) kernel.js:101Kernel: kernel_disconnected (682dc980-d7c6-41e0-b984-14ceb7f8e50c) kernel.js:559Connection lost, reconnecting in 1 seconds. kernel.js:101Kernel: kernel_reconnecting (682dc980-d7c6-41e0-b984-14ceb7f8e50c) kernel.js:456Starting WebSockets: ws://[myipaddress]:[myport]/api/kernels/682dc980-d7c6-41e0-b984-14ceb7f8e50c kernel.js:101Kernel: kernel_connected (682dc980-d7c6-41e0-b984-14ceb7f8e50c) kernel.js:101Kernel: kernel_disconnected (682dc980-d7c6-41e0-b984-14ceb7f8e50c) kernel.js:559Connection lost, reconnecting in 1 seconds. # ... more of the same, over and over ... #

Thing is, everything works fine when I create a notebook on the same machine that runs the Jupyter server (a MacBook I keep at home). The problem happens when I create a notebook from a different machine (a PC running Windows that I use at my company). What could be going on?

Answer1:

I've just changed the port from 8888 to 9999, and the problem is gone.

use the command

jupyter notebook --generate-config

(it says where the generated config file is)

to generate a config file, then find the line

c.NotebookApp.port

and change the port.

Answer2:

I'm using jupyter behind a nginx proxy. I met the same problem as you are. After drill down, I find the problem is existed in my nginx conf.

After adding the following line to my nginx conf, it works!

proxy_http_version 1.1;

Here's the complete nginx conf:

upstream my-notebook-workhorse { server 127.0.0.1:8888 fail_timeout=0; } map $http_upgrade $connection_upgrade { default upgrade; '' close; } # let my-notebook deal with the redirection server { listen 80; server_name my-notebook.wh; server_tokens off; root /dev/null; # Increase this if you want to upload larger attachments client_max_body_size 20m; # individual nginx logs for this vhost access_log /var/log/nginx/my-notebook_access.log; error_log /var/log/nginx/my-notebook_error.log; location / { proxy_pass http://my-notebook-workhorse; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; auth_basic "Restricted Content"; # WebSocket support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header Origin ""; proxy_read_timeout 86400; } }

I don't known why it happens since the old version without proxy_http_version 1.1; worked well in last few months before I met the issue.

Recommend

  • SSRS Show Textbox on last page separately
  • Java applet not working in firefox
  • Get Image uint8 data without canvas
  • how to implement Step definitios from gherkin feature files
  • Is libpq more like a JDBC driver or JavaSE's java.sql package?
  • cannot use raw_input if monkeyrunner is included in python script
  • Three.js - how can I update an arrowHelper?
  • adding a legend to a scatterplot with fitted line and prediction interval
  • TinyXML - any way to skip problematic DOCTYPE tag?
  • Can someone explain how Postgresql roles, Postgresql users and Linux users relate to each other?
  • Problem with sockets and OutOfMemory error
  • draw9patch just hangs on Mac 10.7.5
  • Android SAXParser, parse into array and get child nodes
  • Difference between File>Close and :close in Vim
  • How can i create a big file in google drive with google app script?
  • How to add header and Footer to each activity in android
  • jQuery & CSS - Cut text by height, no truncate
  • How do I clone a class in intellij?
  • Is storing an OAuth token in cookies bad practise?
  • Is it good practice to put Edge Side Includes into my templates?
  • How can I encode a filename according to RFC 2231?
  • k-ary Trees in Java
  • Starting Android AVD crashes with java.awt.HeadlessException
  • Underlying type for Tuple in Swift
  • How can I determine which routines MATLAB uses to solve a sparse matrix?
  • ASPNetCore MVC Routing Let Server Handle Specific Route
  • Using Laravel 5.4 pusher
  • OSX - always hide certain files
  • Compiling dlib on OS X
  • How to generate and display a QR Code in ionic 2
  • Oledb connection string for excel files
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • How do I change content of ComboFieldEditor?
  • Counter field in MS Access, how to generate?
  • Possible to stop flickering java tooltip in heavyweight mode?
  • output of program is not same as passed argument
  • Akka Routing: Reply's send to router ends up as dead letters
  • Arrays break string types in Julia
  • unknown Exception android
  • Checking variable from a different class in C#