404 error with bokeh serve

I’ve taken the Single Module Format example from here and pasted the contents into a file called test2.py:

I then run ‘bokeh serve --show test2.py’. Get the following output:

2025-04-02 09:22:04,483 Starting Bokeh server version 3.6.3 (running on Tornado 6.2)
2025-04-02 09:22:04,486 User authentication hooks NOT provided (default user enabled)
2025-04-02 09:22:04,497 Bokeh app running at: http://localhost:5006/test2
2025-04-02 09:22:04,497 Starting Bokeh server with process id: 43280

However in the browser I get a ‘404: Not found’ error.

There’s no error in the browser console. (Using latest Firefox, Edge is the same).

Reasonably sure this worked when I tried it before with Bokeh 3.6.2.

I’ve tried uninstalling and re-installing Python bokeh package.

Using Python 3.11.0.

Any idea what is wrong?

@quite68 I can’t reproduce any issue. FYI the docs you have linked are for an old version (2.4.2) that is an entire major release (2.x vs 3.x) out of date. Please always refer to the documentation specific to the version you are using (or the latest docs, if you are using the latest version).

https://docs.bokeh.org/en/latest/docs/user_guide/server/app.html#single-module-format

In any case you will need to provide more information: exact URL you tried to open, and any additional log messages (errors like 404s will definitely show up in Bokeh logs, assuming the URL actually results in a request getting sent to the Bokeh server at all)

If you are seeing log errors like this about token expiration on the first use after a fresh install:

HTTPServerRequest(protocol='http', host='localhost:5006', method='GET', uri='/foo/ws', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
  File "/Users/bryan/anaconda3/envs/bk37/lib/python3.13/site-packages/tornado/websocket.py", line 938, in _accept_connection
    open_result = handler.open(*handler.open_args, **handler.open_kwargs)
  File "/Users/bryan/anaconda3/envs/bk37/lib/python3.13/site-packages/tornado/web.py", line 3301, in wrapper
    return method(self, *args, **kwargs)
  File "/Users/bryan/anaconda3/envs/bk37/lib/python3.13/site-packages/bokeh/server/views/ws.py", line 149, in open
    raise ProtocolError("Token is expired. Configure the app with a larger value for --session-token-expiration if necessary")
bokeh.protocol.exceptions.ProtocolError: Token is expired. Configure the app with a larger value for --session-token-expiration if necessary

Then I think that the default session expiration is getting hit while Python compiles all the library .pyc files on first usage. You can re-run or even just re-load the page.