Bokeh App Loading Fail (Bokeh-Flask server using Nginx and Gunicorn )

I am trying to serve my html page with emmbeded bokeh app. Everthing is fine. But bokeh app use port 5006 and it is not loading to the page.
I am getting these errors:

  • WebSocket connection to ‘ws://’ failed: Error during WebSocket handshake: Unexpected response code: 403

  • [bokeh] Failed to connect to Bokeh server Error: Could not open websocket

As far as I understand, nginx handle 5000 port requests but bokeh use 5006 port additively. My server cannot handle that. I couldn’t figure out what I need to do.

My file are :

from WebApp import app

if __name__ == "__main__":

from flask import Flask, render_template, request

from bokeh.embed import server_document

from bokeh.server.server import Server

from tornado.ioloop import IOLoop

from Decision_Tree.Plot.decision_tree import create_figure

app = Flask(__name__)

def modify_doc(doc):

# Create the plot

plot = create_figure()

# Embed plot into HTML via Flask Render


@app.route('/', methods=['GET'])

def bkapp_page():

script = server_document('http://46.101.XXX.XX:5006/bkapp')

return render_template("index.html", script=script, template="Flask")

def bk_worker():

server = Server({'/bkapp': modify_doc}, io_loop=IOLoop(), allow_websocket_origin=["46.101.XXX.XXX:5000"])



from threading import Thread


if __name__ == '__main__':'46.101.XXX.XXX', debug=True)

gunicorn service file:


Description=Gunicorn instance to serve bokeh






ExecStart=/root/bokeh/bokehenv/bin/gunicorn --workers 3 --bind unix:bokeh.sock -m 007 wsgi:app


nginx file:

server {

listen 80;

server_name 46.253.XXX.XXX;

access_log /tmp/bokeh.access.log;

location = /favicon.ico { access_log off; log_not_found off; }

location / {

include proxy_params;

proxy_pass http://unix:/root/bokeh/bokeh.sock;


location /static {

alias /root/bokeh/static;