> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/open-source/new-to-harness-open-source/how-to-use-postgres.md).

# How to use Postgres

Configure Harness Open Source to use an external Postgres database.

By default, Harness Open Source writes an [SQLite](https://www.sqlite.org) database beneath `/data` in the running container.

You can configure Harness Open Source to use an external [Postgres](https://www.postgresql.org/) database.

## Configuration

To configure Harness Open Source to use your Postgres database, set the `GITNESS_DATABASE_DRIVER` and `GITNESS_DATABASE_DATASOURCE` [environment variables](/open-source/new-to-harness-open-source/settings.md) when you launch your Harness Open Source container.

For example:

```sh
docker run -d \
  -e GITNESS_DATABASE_DRIVER=postgres \
  -e GITNESS_DATABASE_DATASOURCE="host=1.2.3.4 port=5678 sslmode=disable dbname=harness user=$USER password=$PASSWORD" \
  -p 3000:3000 -p 3022:3022 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $HOME/harness:/data \
  --name harness \
  --restart always \
  harness/harness
```

`GITNESS_DATABASE_DRIVER` must be `postgres`.

`GITNESS_DATABASE_DATASOURCE` is the [database connection string](/open-source/new-to-harness-open-source/settings.md#gitnessdatabasedatasource) according to your Postgres server configuration. For more information on constructing this string, go to the [Postgres driver documentation](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING).
