Skip to content

Databases

Every product keeps metadata in a database. Each supports SQLite (default) and PostgreSQL.

Product Default Needs PostgreSQL when Config location
Workbench SQLite in /var/lib/rstudio-server Load balancing12 /etc/rstudio/database.conf
Connect SQLite in DataDir/db High availability, and other multi node or containerized environments346 [Database] and [Postgres] in rstudio-connect.gcfg
Package Manager SQLite in DataDir/db High availability910 [Database] and [Postgres] in rstudio-pm.gcfg

Never put SQLite on NFS

SQLite databases on network file systems can become corrupt. Package Manager refuses to start when its SQLite directory is on an NFS mount. If a product's data directory lives on NFS, you have two choices. Move the SQLite directory to local disk (SQLite.Dir in Connect and Package Manager, directory in Workbench database.conf), or switch to PostgreSQL.149

One database per product

Do not share a database between products. Each product needs its own dedicated database and user, even when they share a PostgreSQL server:159

Product Database Notes
Workbench rstudio Default internal database name in the Workbench documentation
Connect connect Optional separate instrumentation database
Package Manager rstudio_pm Optional separate rstudio_pm_usage for usage data

Workbench supports PostgreSQL 13 through 17 (check the requirements page for your version). On PostgreSQL 15 and later, grant schema privileges explicitly or Workbench fails to start with a permission error:1

CREATE DATABASE rstudio;
CREATE USER rstudio WITH PASSWORD '<PASSWORD>';
GRANT ALL PRIVILEGES ON DATABASE rstudio TO rstudio;
\c rstudio
GRANT ALL ON SCHEMA public TO rstudio;

Example configuration

# /etc/rstudio/database.conf  (mode 0600, owned by root)
provider = postgresql
host = postgres.example.com
port = 5432
database = rstudio
username = rstudio
password = <ENCRYPTED_PASSWORD>
[Database]
Provider = "postgres"

[Postgres]
URL = "postgres://connect_user@postgres.example.com/connect?sslmode=require"
Password = "<ENCRYPTED_PASSWORD>"
[Database]
Provider = "postgres"

[Postgres]
URL = "postgres://ppm_user@postgres.example.com/rstudio_pm?sslmode=require"
Password = "<ENCRYPTED_PASSWORD>"
UsageDataURL = "postgres://ppm_user@postgres.example.com/rstudio_pm_usage?sslmode=require"
UsageDataPassword = "<ENCRYPTED_PASSWORD>"

For hosted PostgreSQL such as Amazon RDS or Azure Database for PostgreSQL, Connect's documentation says to include sslmode=require in the connection URL.5 Package Manager uses sslmode=prefer by default.9

Encrypt passwords in config files

Package Manager accepts plain text values for encrypted settings such as Postgres.Password, but logs a message on startup saying the value should have been encrypted.12 Encrypt the password with each product's own command:1117

rspm encrypt
sudo /opt/rstudio-connect/bin/rscadmin encrypt-config-value

If you manage the Connect key yourself with Server.EncryptionKeyFile, use sudo rskey encrypt -f <keyfile> instead.8

sudo rstudio-server encrypt-password

Paste the output into the config file in place of the plain text value. Each product decrypts with a key, so back the key up with the database:811

Product Key
Workbench /var/lib/rstudio-server/secure-cookie-key on a single node; /etc/rstudio/secure-cookie-key, identical on every node, when load balanced2
Connect DataDir/db/secret.key (mode 0600; shared by every HA node)
Package Manager /persistent/encryption/rstudio-pm.key at the [Storage].Persistent location

The Package Manager key also signs and verifies API tokens, so rotating it invalidates every existing token.11

Test connectivity

Before blaming the product, confirm the host can reach the database. The test-postgres-connectivity script checks DNS, TCP, TLS, and a real login. Quick manual checks:

getent hosts postgres.example.com
nc -zv postgres.example.com 5432
psql "host=postgres.example.com port=5432 dbname=rstudio_pm user=ppm_user sslmode=require" -c "select version();"

Pull the URL straight from a config file to test exactly what the product uses:

sudo grep -A3 '^\[Postgres\]' /etc/rstudio-pm/rstudio-pm.gcfg

On managed PostgreSQL, a timeout usually means the server's firewall does not allow the VM's IP. Confirm the source IP with hostname -I and ask the database team to allow it.