Search code examples
pythonbokehweb-development-server

How do I setup a bokeh application such that it can be accessed through the internet?


Note from maintainers: This question as originally posed is in regards to the first generation Bokeh server which no longer exists. For information about running modern Bokeh server applications, see Running A Bokeh Server in the docs.


I want to set up an interactive bokeh app, which can be accessed by anyone over the internet.

For understanding, how this works, I am currently trying to get the stocks example running, such that I can access it, for example, from my mobile phone.

I have already tried the following:

  • opened port 5006 and 5050 and tried to access the App over http:\\<my_global_ip>:<port>
  • studied the html source of http://docs.bokeh.org/en/latest/docs/server_gallery/stocks_server.html and figure out what's the difference of that source to the generated source code

So far I got the whole example running on the computer, where the bokeh server is running, such that I can access it via localhost:5006/bokeh/stocks/ and localhost:5050/. But as soon as I try to access it from another machine, I see the html content, but not the plot.

Edit: I'm trying to run the example at https://github.com/bokeh/bokeh/tree/master/examples/deploy because it sounds promising, but because I do not really understand what I'm doing here I would appreciate clarification. I don't get the example working, anyhow. Installation of gunicorn with conda only worked after some headaches and finally the provided commands run, but I do not get any response on port 5006 or port 7001. Perhaps I'm just misunderstanding the example?


Solution

  • Modern Bokeh versions:

    You need to specify what websocket origins are permitted to connect:

    https://docs.bokeh.org/en/latest/docs/user_guide/server.html#websocket-origin

    E.g.

    bokeh serve --show --allow-websocket-origin=foo.com sliders.py
    

    For Bokeh version 0.11

    Due to changes in the bokeh server now you need to call

    bokeh serve sliders.py --host <globalip>:5006
    

    Nothing else is needed.

    Please note that you have to change the code for your app as well!

    See https://github.com/bokeh/bokeh/blob/master/examples/app/sliders.py for the updated sliders app.