How to shutdown a JupyterDash app in external mode?


I’m running app.run_server(debug=True, mode='external') from a jupyter notebook and my app runs on

Is there a way to shutdown the server without restarting the jupyter kernel?

(So that the address is free for another app, for example, to run from the command line - which currently produces OSError: [Errno 98] Address already in use.)

I tried to run'') which I found here - Shutdown dash app after n seconds - #3 by W_R, but I get <Response [500]>.

Thanks, JupyterDash is a great addition by the way!

1 Like

Bumping this to hopefully get an answer?

Seems like I found the answer myself perusing the source code at

JupyterDash has a classmethod called _terminate_server_for_port:

    def _terminate_server_for_port(cls, host, port):
        shutdown_url = "http://{host}:{port}/_shutdown_{token}".format(
            host=host, port=port, token=JupyterDash._token
            response = requests.get(shutdown_url)
        except Exception as e:

So if you start a JupyterDash server like:

from jupyter_dash import JupyterDash

app = JupyterDash()
app.layout. = html.Div()
app.run_server(mode='external', port=8060)

You can then run app._terminate_server_for_port("localhost", 8060) to kill the server.

Mind you this is a private method, so guess we’re not supposed to use it, but when in need…


Works perfectly, thanks a lot!

Doesn’t work anymore… :frowning:

1 Like