Running and debugging

Shiny apps can be previewed using the shiny command line interface (CLI), or directly from IDEs like Visual Studio Code and RStudio.

Demo Application

This page assumes that you’ve created an app in your my_app/ folder called

A quick way to do this is using the shiny create command.

# create demo file: my_app/
shiny create my_app

Alternatively, you can copy in this tiny app code into my_app/

from shiny import App, ui

app_ui = ui.page_fluid(ui.h1("My App"))

app = App(app_ui, None)

Running with the shiny CLI

Use the shiny CLI’s run command to preview your application.

# create and run demo
shiny create my_app
shiny run --reload my_app/

Note that the --reload flag will reload the app whenever the file changes.

Running in Visual Studio Code


VS Code integration is currently a work in progress.

In the top bar, click “Terminal” followed by “New Terminal”.

In the new terminal pane, enter the commands from the “Running with the Shiny CLI” section:

shiny run --reload my_app/

Running in RStudio IDE


RStudio IDE integration is currently a work in progress.

To run a Shiny application from the RStudio IDE, click on “Tools” in the menu bar. Then, select “Terminal” followed by “New Terminal”. This will open a terminal tab next to your R console.

In the terminal pane, enter the commands from the “Running with the shiny CLI” section:

shiny run --reload my_app/


Showing error in outputs

One way that Shiny helps with debugging server logic is by showing errors where their output would be.

For example, the report_check function in the app below erroneously references a variable that doesn’t exist.

#| standalone: true
from shiny import App, ui, render

app_ui = ui.page_fluid(

def server(input, output, session):
    def report_check():
        return str(a_missing_variable)

    def another_output():
        return "This output is looking good"

app = App(app_ui, server)

Notice that the error about 'a_missing_variable' is not defined is where the report_check output would normally go.

The error displayed in the app is only the final part of the stack trace, but the full trace can be read in the console where you used shiny run.

Setting debug mode

An advanced option for debugging apps is using the App(..., debug=True) argument. This is not super useful in general, as it requires some knowledge of Shiny’s internals.

In debug mode, Shiny applications log in the console all of the messages that the server sends and receive from browser sessions. This is the raw data behind how changes to inputs cause calculations on the server, and how messages from the server cause the client’s browser to update (e.g. a plot).

Here is a short log example.

SEND: {"busy": "busy"}
SEND: {"recalculating": {"name": "my_cool_output", "status": "recalculating"}}
SEND: {"recalculating": {"name": "my_cool_output", "status": "recalculated"}}
SEND: {"busy": "idle"}
SEND: {"values": {}, "inputMessages": [], "errors": {}}

Note also that Shiny applications use Python’s asyncio under the hood, so it may be useful to set asyncio’s debug mode.


See the deploy page for how to deploy Shiny applications.