Hi - I’ve been using the bokeh server to serve some web pages, and noted that sometimes it just serves a blank page. After refreshing the web page several times, I can usually get it to display.
I’m using a headless bokeh server running on a Linux box, and Tailscale VPN to access the server. Here’s a minimal example:
from bokeh.io import curdoc
from bokeh.models import Div
from bokeh.layouts import column, row
# Test where we are
print(f"Executing script for Session ID: \
{curdoc().session_context.id if curdoc().session_context else 'Initial Server Start'}")
# Set up initial message while processing
status_div = Div(text='Testing...')
layout = column(status_div)
curdoc().add_root(layout)
curdoc().title = "TEST"
I serve this with the invocation:
bokeh serve ~/webapp/bserve_test.py --allow-websocket-origin=* --log-level trace
About 50% of the time, when opening or refreshing a webpage, I’ll just get a blank page. Here’s the log output when this happens:
2026-02-26 15:30:00,741 Starting Bokeh server version 3.8.2 (running on Tornado 6.5.2)
2026-02-26 15:30:00,742 Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. Use non-wildcard values to restrict access explicitly
2026-02-26 15:30:00,742 User authentication hooks NOT provided (default user enabled)
2026-02-26 15:30:00,742 These host origins can connect to the websocket: ['*']
2026-02-26 15:30:00,743 Patterns are:
2026-02-26 15:30:00,743 [('/favicon.ico',
2026-02-26 15:30:00,743 <class 'bokeh.server.views.ico_handler.IcoHandler'>,
2026-02-26 15:30:00,743 {'app': <bokeh.server.tornado.BokehTornado object at 0x7fff0cfe80d0>}),
2026-02-26 15:30:00,743 ('/bserve_test/?',
2026-02-26 15:30:00,743 <class 'bokeh.server.views.doc_handler.DocHandler'>,
2026-02-26 15:30:00,743 {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7fff0d1c92d0>,
2026-02-26 15:30:00,743 'bokeh_websocket_path': '/bserve_test/ws'}),
2026-02-26 15:30:00,743 ('/bserve_test/ws',
2026-02-26 15:30:00,743 <class 'bokeh.server.views.ws.WSHandler'>,
2026-02-26 15:30:00,743 {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7fff0d1c92d0>,
2026-02-26 15:30:00,743 'bokeh_websocket_path': '/bserve_test/ws',
2026-02-26 15:30:00,743 'compression_level': None,
2026-02-26 15:30:00,743 'mem_level': None}),
2026-02-26 15:30:00,743 ('/bserve_test/metadata',
2026-02-26 15:30:00,743 <class 'bokeh.server.views.metadata_handler.MetadataHandler'>,
2026-02-26 15:30:00,743 {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7fff0d1c92d0>,
2026-02-26 15:30:00,743 'bokeh_websocket_path': '/bserve_test/ws'}),
2026-02-26 15:30:00,743 ('/bserve_test/autoload.js',
2026-02-26 15:30:00,743 <class 'bokeh.server.views.autoload_js_handler.AutoloadJsHandler'>,
2026-02-26 15:30:00,743 {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7fff0d1c92d0>,
2026-02-26 15:30:00,743 'bokeh_websocket_path': '/bserve_test/ws'}),
2026-02-26 15:30:00,744 ('/bserve_test/static/(.*)',
2026-02-26 15:30:00,744 <class 'bokeh.server.views.static_handler.StaticHandler'>,
2026-02-26 15:30:00,744 {}),
2026-02-26 15:30:00,744 ('/?',
2026-02-26 15:30:00,744 <class 'bokeh.server.views.root_handler.RootHandler'>,
2026-02-26 15:30:00,744 {'applications': {'/bserve_test': <bokeh.server.contexts.ApplicationContext object at 0x7fff0d1c92d0>},
2026-02-26 15:30:00,744 'index': None,
2026-02-26 15:30:00,744 'prefix': '',
2026-02-26 15:30:00,744 'use_redirect': True}),
2026-02-26 15:30:00,744 ('/static/extensions/(.*)',
2026-02-26 15:30:00,744 <class 'bokeh.server.views.multi_root_static_handler.MultiRootStaticHandler'>,
2026-02-26 15:30:00,744 {'root': {}}),
2026-02-26 15:30:00,744 ('/static/(.*)',
2026-02-26 15:30:00,744 <class 'bokeh.server.views.static_handler.StaticHandler'>)]
2026-02-26 15:30:00,746 Bokeh app running at: http://localhost:5006/bserve_test
2026-02-26 15:30:00,746 Starting Bokeh server with process id: 263917
2026-02-26 15:30:15,758 Running stats log job
2026-02-26 15:30:15,758 [pid 263917] 0 clients connected
2026-02-26 15:30:15,758 [pid 263917] /bserve_test has 0 sessions with 0 unused
2026-02-26 15:30:17,749 Running session cleanup job
2026-02-26 15:30:30,759 Running stats log job
2026-02-26 15:30:30,759 [pid 263917] 0 clients connected
2026-02-26 15:30:30,759 [pid 263917] /bserve_test has 0 sessions with 0 unused
2026-02-26 15:30:34,751 Running session cleanup job
Executing script for Session ID: 8TD7613Ts8mGav4biPuOjChyvjRTQSYHELQp9X0QkBAE
2026-02-26 15:30:37,747 Running keep alive job
2026-02-26 15:30:45,753 Running stats log job
2026-02-26 15:30:45,753 [pid 263917] 0 clients connected
2026-02-26 15:30:45,753 [pid 263917] /bserve_test has 1 sessions with 1 unused
2026-02-26 15:30:51,751 Running session cleanup job
2026-02-26 15:31:00,753 Running stats log job
2026-02-26 15:31:00,753 [pid 263917] 0 clients connected
2026-02-26 15:31:00,753 [pid 263917] /bserve_test has 1 sessions with 1 unused
2026-02-26 15:31:08,749 Running session cleanup job
2026-02-26 15:31:08,749 Scheduling 1 sessions to discard
2026-02-26 15:31:08,749 Discarding session '8TD7613Ts8mGav4biPuOjChyvjRTQSYHELQp9X0QkBAE' last in use 31677.471142053604 milliseconds ago
2026-02-26 15:31:08,750 Deleting 1 modules for document <bokeh.document.document.Document object at 0x7fff0d059cd0>
2026-02-26 15:31:08,814 Session '8TD7613Ts8mGav4biPuOjChyvjRTQSYHELQp9X0QkBAE' was successfully discarded
So no connection to the client, although a session is started. Can anyone tell me what is happening here?