Bokeh Server not showing up in jupyterlab in a docker container

I am trying to get a bokeh server to run in a jupyter notebook in jupyter lab (I’m specifically interested in using python callbacks in the notebook, so if there is another way to do that, feel free to chime in), which is running in a docker container on os X.

When I try and use the example ‘notebook_embed.ipynb’, I get no output after running the notebook, other than the ‘BokehJS 2.3.1 successfully loaded.’ text when running ‘output_notebook’.

I have changed the show command to: show(bkapp, notebook_url="http://localhost:52947"), which is the port and host that my jupyter notebook is accessed at. I have also tried show(bkapp, notebook_url="http://localhost:8888") which is the internal port that jupyterlab is hosting it at.

I’m not sure how to debug this… anyone have any ideas?

1 Like

Ok, Some more information:

In the Javascript console, I’m getting this error when I run the cell that has the show(bkapp, notebook_url="http://localhost:8888/"):

VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
VM607 bokeh-2.3.1.min.js:165 [bokeh] document idle at 126 ms
VM607 bokeh-2.3.1.min.js:165 [bokeh] document idle at 17 ms
VM607 bokeh-2.3.1.min.js:165 [bokeh] document idle at 16 ms
VM607 bokeh-2.3.1.min.js:165 [bokeh] document idle at 582 ms
:44479/autoload.js?bokeh-autoload-element=6036&bokeh-absolute-url=http://localhost:44479&resources=none:1 Failed to load resource: net::ERR_EMPTY_RESPONSE
:34925/autoload.js?bokeh-autoload-element=6038&bokeh-absolute-url=http://localhost:34925&resources=none:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
:46051/autoload.js?bokeh-autoload-element=1003&bokeh-absolute-url=http://localhost:46051&resources=none:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
:33581/autoload.js?bokeh-autoload-element=1004&bokeh-absolute-url=http://localhost:33581&resources=none:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
:37209/autoload.js?bokeh-autoload-element=1005&bokeh-absolute-url=http://localhost:37209&resources=none:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
VM607 bokeh-2.3.1.min.js:165 [bokeh] document idle at 1367 ms
VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
VM607 bokeh-2.3.1.min.js:165 [bokeh] document idle at 1168 ms
VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
VM607 bokeh-2.3.1.min.js:165 [bokeh] document idle at 1045 ms
VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
VM607 bokeh-2.3.1.min.js:165 [bokeh] document idle at 718 ms
VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
VM607 bokeh-2.3.1.min.js:165 [bokeh] document idle at 619 ms
jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2 Connection lost, reconnecting in 0 seconds.
_reconnect @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2 Connection lost, reconnecting in 0 seconds.
_reconnect @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2 Connection lost, reconnecting in 0 seconds.
_reconnect @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2 Connection lost, reconnecting in 0 seconds.
_reconnect @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2 Connection lost, reconnecting in 0 seconds.
_reconnect @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
:35671/autoload.js?bokeh-autoload-element=1006&bokeh-absolute-url=http://localhost:35671&resources=none:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
:34909/autoload.js?bokeh-autoload-element=1013&bokeh-absolute-url=http://localhost:34909&resources=none:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
VM1090:13 GET http://localhost:46165/autoload.js?bokeh-autoload-element=1014&bokeh-absolute-url=http://localhost:46165&resources=none net::ERR_CONNECTION_REFUSED
(anonymous) @ VM1090:13
t.attachWidget @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
t.insertWidget @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_insertOutput @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
onModelChanged @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
m @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
l @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
e.emit @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_onListChanged @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
m @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
l @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
e.emit @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
push @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_add @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
add @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_onIOPub @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_handleIOPub @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
async function (async)
_handleIOPub @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
handleMsg @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_handleMessage @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
(anonymous) @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
Promise.then (async)
C._onWSMessage @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2 Last saving performed Sun Apr 18 2021 14:15:01 GMT-0600 (Mountain Daylight Time) while the current file seems to have been saved Sun Apr 18 2021 14:19:51 GMT-0600 (Mountain Daylight Time)
_timeConflict @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
(anonymous) @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
Promise.then (async)
_maybeSave @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_save @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
async function (async)
_save @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
(anonymous) @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
Promise.then (async)
save @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_save @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
(anonymous) @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
VM607 bokeh-2.3.1.min.js:585 WebSocket connection to 'ws://localhost:46811/ws' failed: 
connect @ VM607 bokeh-2.3.1.min.js:585
n.pull_session @ VM607 bokeh-2.3.1.min.js:585
(anonymous) @ VM607 bokeh-2.3.1.min.js:584
t.add_document_from_session @ VM607 bokeh-2.3.1.min.js:584
w @ VM607 bokeh-2.3.1.min.js:163
t.embed_items @ VM607 bokeh-2.3.1.min.js:163
VM607 bokeh-2.3.1.min.js:585 [bokeh] Failed to connect to Bokeh server: Could not open websocket
_on_error @ VM607 bokeh-2.3.1.min.js:585
socket.onerror @ VM607 bokeh-2.3.1.min.js:585
error (async)
(anonymous) @ VM607 bokeh-2.3.1.min.js:585
connect @ VM607 bokeh-2.3.1.min.js:585
n.pull_session @ VM607 bokeh-2.3.1.min.js:585
(anonymous) @ VM607 bokeh-2.3.1.min.js:584
t.add_document_from_session @ VM607 bokeh-2.3.1.min.js:584
w @ VM607 bokeh-2.3.1.min.js:163
t.embed_items @ VM607 bokeh-2.3.1.min.js:163
async function (async)
t.embed_items @ VM607 bokeh-2.3.1.min.js:163
embed_document @ a8407267-2dac-4132-a535-dea951728e9e:114
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:118
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:134
o.safely @ VM607 bokeh-2.3.1.min.js:593
fn @ a8407267-2dac-4132-a535-dea951728e9e:108
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:137
inline_js @ a8407267-2dac-4132-a535-dea951728e9e:139
run_inline_js @ a8407267-2dac-4132-a535-dea951728e9e:150
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:161
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:27
run_callbacks @ a8407267-2dac-4132-a535-dea951728e9e:25
load_libs @ a8407267-2dac-4132-a535-dea951728e9e:45
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:159
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:164
VM607 bokeh-2.3.1.min.js:584 [bokeh] Failed to load Bokeh session js9sLeh2fppD2cdA0YvHNR4zw8grmMgwOkm7bunJXFZc: Error: Could not open websocket
t.add_document_from_session @ VM607 bokeh-2.3.1.min.js:584
async function (async)
t.add_document_from_session @ VM607 bokeh-2.3.1.min.js:584
w @ VM607 bokeh-2.3.1.min.js:163
t.embed_items @ VM607 bokeh-2.3.1.min.js:163
async function (async)
t.embed_items @ VM607 bokeh-2.3.1.min.js:163
embed_document @ a8407267-2dac-4132-a535-dea951728e9e:114
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:118
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:134
o.safely @ VM607 bokeh-2.3.1.min.js:593
fn @ a8407267-2dac-4132-a535-dea951728e9e:108
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:137
inline_js @ a8407267-2dac-4132-a535-dea951728e9e:139
run_inline_js @ a8407267-2dac-4132-a535-dea951728e9e:150
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:161
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:27
run_callbacks @ a8407267-2dac-4132-a535-dea951728e9e:25
load_libs @ a8407267-2dac-4132-a535-dea951728e9e:45
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:159
(anonymous) @ a8407267-2dac-4132-a535-dea951728e9e:164
VM607 bokeh-2.3.1.min.js:163 Error rendering Bokeh items: Error: Could not open websocket
    at d._on_error (VM607 bokeh-2.3.1.min.js:585)
    at WebSocket.socket.onerror (VM607 bokeh-2.3.1.min.js:585)
VM607 bokeh-2.3.1.min.js:585 [bokeh] Lost websocket 0 connection, 1006 ()
VM607 bokeh-2.3.1.min.js:585 [bokeh] Websocket connection 0 disconnected, will not attempt to reconnect
VM607 bokeh-2.3.1.min.js:184 [bokeh] setting log level to: 'info'
VM1101:13 GET http://localhost:45897/autoload.js?bokeh-autoload-element=1101&bokeh-absolute-url=http://localhost:45897&resources=none net::ERR_CONNECTION_REFUSED
(anonymous) @ VM1101:13
t.attachWidget @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
t.insertWidget @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_insertOutput @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
onModelChanged @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
m @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
l @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
e.emit @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_onListChanged @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
m @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
l @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
e.emit @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
push @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_add @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
add @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_onIOPub @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_handleIOPub @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
async function (async)
_handleIOPub @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
handleMsg @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_handleMessage @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
(anonymous) @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
Promise.then (async)
C._onWSMessage @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
VM1102:13 GET http://localhost:32851/autoload.js?bokeh-autoload-element=1102&bokeh-absolute-url=http://localhost:32851&resources=none net::ERR_CONNECTION_REFUSED
(anonymous) @ VM1102:13
t.attachWidget @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
t.insertWidget @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_insertOutput @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
onModelChanged @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
m @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
l @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
e.emit @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_onListChanged @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
m @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
l @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
e.emit @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
push @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_add @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
add @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_onIOPub @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_handleIOPub @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
async function (async)
_handleIOPub @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
handleMsg @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
_handleMessage @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
(anonymous) @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2
Promise.then (async)
C._onWSMessage @ jlab_core.64abc115a1efeec58694.js?v=64abc115a1efeec58694:2

Which is showing a bunch of random ports on localhost that are being tried in order to connect. If I understand this correctly, the cell is trying to call out to a bokeh server on the docker container, but it can’t reach because the correct port isn’t being forwarded.

How do I get the bokeh server to choose a single port? (I can then open up that port on the docker container to make this work).

1 Like

@spott You should be able to pass a port keyword argument to show to fix the port that the Bokeh server instance listens on. By default it uses port=0 which picks a random open port. Note that fixing a port means that running the show a second time will certainly fail (the port will still be in use).

@spott By default it uses port=0 which picks a random open port. That is the problem i think. :slightly_smiling_face:

I apologize, I missed that I got responses here.

I tried the port thing, but I’m getting these errors now:

WARNING:tornado.access:404 GET /favicon.ico (127.0.0.1) 0.43ms
ERROR:bokeh.server.views.ws:Refusing websocket connection from Origin 'http://localhost:56000';                       use --allow-websocket-origin=localhost:56000 or set BOKEH_ALLOW_WS_ORIGIN=localhost:56000 to permit this; currently we allow origins {'localhost:54281'}
WARNING:tornado.access:403 GET /ws (127.0.0.1) 1.39ms