# Doppler Setup on Ubuntu 22.04 Gunicorn Nginx FastApi

**URL:** <https://community.doppler.com/t/doppler-setup-on-ubuntu-22-04-gunicorn-nginx-fastapi/1008>\
**Category:** Need Help\
**Created:** [February 21, 2023, 5:49pm UTC](https://community.doppler.com/t/doppler-setup-on-ubuntu-22-04-gunicorn-nginx-fastapi/1008 "2023-02-21T17:49:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![manfred\_beluga](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/manfred_beluga/32/698_2.png) [@manfred\_beluga](https://community.doppler.com/u/manfred_beluga)\
**Post date:** [February 21, 2023, 5:49pm UTC](https://community.doppler.com/t/doppler-setup-on-ubuntu-22-04-gunicorn-nginx-fastapi/1008/1 "2023-02-21T17:49:06Z")

</div>

HI, I am trying to start using doppler.

I have a fastapi application that is run via gunicorn and served via nginx.

Currently I restart my application via:

$ sudo systemctl daemon-reload  
$ sudo systemctl restart gunicorn  
$ sudo systemctl status gunicorn

With doppler i tried the same but adding doppler run – in front, however, it does not work as my application cannot access the secrets.

If I run $ doppler run --command=“echo $SECRET\_NAME” then I also get the secrets echoed.

What should I do to make the application work?

Any suggestions?

Thanks so much.

Manfred

---

<div class="post-metadata">

**Author:** ![watsonian](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/watsonian/32/267_2.png) [@watsonian](https://community.doppler.com/u/watsonian)\
**Post date:** [February 21, 2023, 8:58pm UTC](https://community.doppler.com/t/doppler-setup-on-ubuntu-22-04-gunicorn-nginx-fastapi/1008/2 "2023-02-21T20:58:26Z")

</div>

Hi @manfred_beluga!

Welcome to the Doppler Community!

Could you post the systemd unitfile you’re using to gunicorn? Without seeing that exactly, the main thing I can think of is that you might not be setting a `DOPPLER_TOKEN` in the `EnvironmentFile` for the unitfile. You would need that set to a [service token](https://docs.doppler.com/docs/service-tokens). Then if you executed gunicorn using `doppler run -- ...` then it should load everything into the environment. From there, based on what I’ve gathered around FastAPI applications, you’d access them in your application by doing something like this:

```auto
from fastapi import FastAPI
from pydantic import BaseSettings, Field, SecretStr

class Settings(BaseSettings):
    # Field required since case-insensitive match wasn't possible
    project: str = Field(..., env="DOPPLER_PROJECT")
    # Field required since case-insensitive match wasn't possible
    config: str = Field(..., env="DOPPLER_CONFIG")
    # matches DB_URL in Doppler
    db_url: SecretStr
    # matches AUTH in Doppler
    auth: SecretStr

settings = Settings()
app = FastAPI()

@app.get("/")
def read_root():
    return {"Project": settings.project, "Config": settings.config, "Auth": settings.auth}

```

If you’re already doing something like that, posting your unitfile should be helpful!

Regards,  
-Joel
