# Connection with n8n

Source: https://docs.sliplane.io/databases/gui/n8n

Connect to your Sliplane database with n8n.

[n8n](https://n8n.io/) is an open-source workflow automation tool. You can use a Sliplane database with n8n in two ways: as n8n's own backing database (recommended for self-hosting), or as a data source inside a workflow through the Postgres node.

> **info**
>
> Deploy with the Sliplane preset:
>
> [Deploy n8n](https://sliplane.io/app/deploy?presetId=n8n)

## Before you start

Open your Sliplane database to find its connection details.

## Use as n8n's backing database

By default, self-hosted n8n stores its workflows, credentials, and execution data in a local SQLite file. For production you should use a database like PostgreSQL instead, so your data lives in a managed database with backups and survives container restarts.

Keep the preset’s `/home/node/.n8n` volume attached: it stores the encryption key needed to read saved credentials, even when using PostgreSQL.

For an existing SQLite installation, [export and import your data](https://docs.n8n.io/deploy/host-n8n/configure-n8n/use-the-command-line) before switching databases.

Point n8n at your Sliplane database by setting the following environment variables on your n8n service:

```bash
DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=YOUR_DATABASE_HOST
DB_POSTGRESDB_PORT=YOUR_DATABASE_PORT
DB_POSTGRESDB_DATABASE=DATABASE_NAME
DB_POSTGRESDB_USER=USERNAME
DB_POSTGRESDB_PASSWORD=PASSWORD
DB_POSTGRESDB_SSL_CA=<CA certificate, see below>
```

Setting `DB_POSTGRESDB_SSL_CA` lets n8n verify the database server's TLS certificate. Paste the CA certificate as the value below:

**CA certificate**

```text title="isrgrootx1.pem"
-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXA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/KK
NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
-----END CERTIFICATE-----
```

Restart n8n after setting these. On the next start, n8n runs its migrations against your database and uses it for database-backed state.

> **info**
>
> If you deployed n8n on Sliplane, you can open your dashboard and set them in the **Environment Variables**:
>
> ![n8n environment variables on Sliplane](/_next/static/media/n8n-postgres-sliplane-env.8e4996a0.webp)
>
> After adding, click the **Save and redeploy** button to apply the new environment variables.

## Use in a workflow with the Postgres node

If you instead want to read from and write to a Sliplane database as part of a workflow, add a Postgres node and configure a credential.

1. Open n8n. In the left sidebar, click &#x2A;*+** then **Credentials**.

2. Search for and select **Postgres**.

3. Fill in the connection settings:

   * **Host** — the host from the dashboard
   * **Database** — the database from the dashboard
   * **User** — the user from the dashboard
   * **Password** — the password from the dashboard
   * **Port** — the port from the dashboard

4. Set **SSL** to **require**.

   ![N8N Postgres SSL settings](/_next/static/media/n8n-postgres-ssl-setting.de929fde.webp)

5. Click **Save**. n8n tests the connection and confirms it succeeded.

You can now add a **Postgres** node to any workflow, select this credential, and run queries against your database.
