# Deployment Tips for Gunicorn

**URL:** <https://discourse.holoviz.org/t/deployment-tips-for-gunicorn/2744>\
**Category:** Panel\
**Tags:** panel\
**Created:** [August 31, 2021, 6:17pm UTC](https://discourse.holoviz.org/t/deployment-tips-for-gunicorn/2744 "2021-08-31T18:17:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![\_jm](https://discourse.holoviz.org/letter_avatar_proxy/v4/letter/_/ac91a4/32.png) [@\_jm](https://discourse.holoviz.org/u/_jm)\
**Post date:** [September 1, 2021, 2:19pm UTC](https://discourse.holoviz.org/t/deployment-tips-for-gunicorn/2744/2 "2021-09-01T14:19:42Z")

</div>

Hi @jamiec

A typical way to use gunicorn with a bokeh server is to leverage Flask to integrate the bokeh server sessions.

You can refer to the flask\_gunicorn\_embed.py example in the bokeh GitHub repository for details. See[server embed (flask\_gunicorn\_embed.py)](https://github.com/bokeh/bokeh/tree/branch-2.4/examples/howto/server_embed).

The readme there indicates running with

`gunicorn -w 4 flask_gunicorn_embed:app`

But, the gunicorn command can also be used as normal with a config file rather than specifying options like the number of workers (–w 4) on the command line.

The panel server is built on top of the bokeh server, so to get things to work under panel, only minimal changes are required. For the above-referenced flask\_gunicorn\_embed.py example, one way to accomplish this is to implement the following change (i.e. comment out the bokeh `doc.add_root()` statement and replace with panel layout and `server_doc()` statements; and obviously include the panel import).

```auto
#doc.add_root(column(slider, plot))
_col = pn.Column(slider, plot)
_col.server_doc(doc)

```

Note: There have been periodic recent regressions in panel that cause layouts to not render properly. See the following panel discourse topic for details.

> [@Panel regression? (embedding panel in gunicorn+Flask)](https://discourse.holoviz.org/t/panel-regression-embedding-panel-in-gunicorn-flask/1724):
>
> I previously developed an application that embeds a panel server in Flask running via gunicorn that uses panel 0.9.7. After upgrading to panel 0.10.2, in order to incorporate new features, e.g. a panel Card layout, things no longer work. The symptom of not working is no UI widgets or bokeh figures in the panels being rendered, and a collection of ERR\_ABORTED 404 (NOT FOUND) errors in the JavaScript console of the client browser. To rule out anything related to my quite-involved application, I …

---

_[View the full topic](https://discourse.holoviz.org/t/deployment-tips-for-gunicorn/2744)._
