Running Bokeh Server in Vagrant VE

Hi All,

I’ve been stuck for a while now trying to get an interactive bokeh plot working with Django. I think I’ve narrowed my issue down a little bit. I was able to run a few of the app and embed examples on my local machine (Ubuntu 16.04), for instance the animated example. However, my Django app is being run in a ve with Vagrant, and in my VE, using the same sequence of commands that worked in my local environment, I get a connection error.

My vagrant file has the following:

Create a forwarded port mapping which allows access to a specific port

within the machine from a port on the host machine. In the example below,

accessing “localhost:8080” will access port 80 on the guest machine.

#config.vm.network “forwarded_port”, guest: 8000, host: 8080

config.vm.network “forwarded_port”, host: 4567, guest: 5006

config.vm.network “forwarded_port”, guest: 8888, host: 8889

Create a private network, which allows host-only access to the machine

using a specific IP.

config.vm.network “private_network”, ip: “192.168.56.10”

The last two ‘forward port’ lines I’ve added trying suggestions from this discussion board and elsewhere.

So from the terminal in my ve (after vagrant up, ssh, source/bin/activate, etc), in the project folder I first run:

bokeh serve --allow-websocket-origin=localhost:8000

And the output is:

2017-08-13 21:38:32,353 Starting Bokeh server version 0.12.6 (running on Tornado 4.5.1)

2017-08-13 21:38:32,357 Starting Bokeh server on port 5006 with applications at paths [’/’]

2017-08-13 21:38:32,358 Starting Bokeh server with process id: 2235

Then I open a new terminal, ssh into vagrant, activate my ve and navigate to the folder where my example python file is and execute the file:

python bokeh_test.py

The output in the current window is:

To view this example, first start a Bokeh server:

bokeh serve --allow-websocket-origin=localhost:8000

And then load the example into the Bokeh server by

running the script:

python animated.py

in this directory. Finally, start a simple web server

by running:

python -m SimpleHTTPServer (python 2)

or

python -m http.server (python 3)

in this directory. Navigate to

http://localhost:8000/animated.html

And in the bokeh terminal window I see the websocket open:

2017-08-13 21:38:58,300 101 GET /ws?bokeh-protocol-version=1.0&bokeh-session-id=H32hRkfM1BRNMUPjydwAnhl3EJGiYNUKa6VmEGeuTJ9F (127.0.0.1) 0.66ms

2017-08-13 21:38:58,300 WebSocket connection opened

2017-08-13 21:38:58,300 ServerConnection created

Then I open another new terminal window, same steps as above to get into ve, and I run:

python -m http.server

And the output is:

Serving HTTP on 0.0.0.0 port 8000 …

I see that animated.html has been created in the folder, and so I navigate to localhost:8000/animate.html

And in chrome dev tools I see the error:

GET http://localhost:8000/animated.html net::ERR_CONNECTION_REFUSED

Again, this works on my local machine. Any suggestions are greatly appreciated!

Thanks!