OSError: Cannot pull session document because we failed to connect to the server

Bokeh - 2.0.2
python- 3.8
Django- 3.0.6

def bkapp_page(request):
with pull_session(url=“http://localhost:5006/Interactive”) as session:
# update or customize that session
session.document.roots[0].children[1].title.text = “Special Sliders For A Specific User!”

    # generate a script to load the customized session
    script = server_session(session_id=session.id, url="http://localhost:5006/Interactive")

    # use the script in the rendered page
    return render(request, "embed.html", dict(script=script))

This is the code I extracted from the website and the only errror it gives me : OSError: Cannot pull session document because we failed to connect to the server
What am I doing wrong?

Hi @Clinton_Emok please edit your post to use code formatting so that the code is intelligible (either with the </> icon on the editing toolbar, or triple backtick ``` fences around the code blocks)

That code is for embedding a session from separate running Bokeh server, are you running a Bokeh server?

I am running a Bokeh server before calling this function on Django so I don’t understand why that error pops up

def bkapp_page(request):
with pull_session(url=“http://localhost:5006/Interactive”) as session:
session.document.roots[0].children[1].title.text = “Special Sliders For A Specific User!”
script = server_session(session_id=session.id, url="http://localhost:5006/Interactive")
return render(request, "embed.html", dict(script=script))

I just noticed you have a "localhost" URL in your embed calls. Are you running this locally or on some service that you are connecting to from remotely If locally, can you actually navigate to localhost:5006/interactive and connect to the Bokeh app directly? If remotely, that will never work because the browser will try to connect to “localhost” which is not where the bokeh server is running. The error message means that the Bokeh app cannot be reached, which could be several possible things:

  • You are running an app, but not one called “interactive”
  • There is some network configuration in between preventing the connection
  • You are trying to connect remotely and have specified “locahost”

You need to be more specific about what processes you are running, where you are running then, how exactly you are running them (what commands), and where you are trying to connect from.

I am currently running a bokeh server that gets posted to localhost:5006/Interactive using the command :

bokeh serve --show Interactive.ipynb

I currently testing everything locally with my Django address : (myip):8000
I’m calling the server to show up on :8000/interactive specifed in my views.py
I intialize the bokeh server to see if it posts then I run my Django app
The bokeh server posts and works! See below


Anything you still need?