In Plotly Enterprise 2.5.0 and up, you can store secrets as environment variables
instead of hardcoded in your application code.
It’s good practice to keep application
secrets like database passwords outside of your code so that they aren’t
mistakenly exposed or shared. Instead of storing these secrets in code,
you can store them as environment variables and your Dash Application code
can reference them dynamically.
To add environment variables via the Dash Enterprise UI,
navigate to the application settings. Here, use the text boxes to
add the environmental variable name and value. For example,
You can reference these variables with the
Alternatively, if the variable isn’t in your environment and you want
to fall back to some other value, use:
By referencing these environment variables in our code, we’ll need to add
these variables to our local environment as well. One easy way to do
this is to define the variables on-the-fly when you run
That is, instead of running
python app.py, run:
$ DATABASE_USER=chris DATABASE_PASSWORD=my-password python app.py
Alternatively, you can define them for your session by “exporting” them:
To remove an environment variable via the Dash Enterprise UI,
navigate to the application settings. Here, simply click the red
cross situated to the right-hand side of the environment variable.