Persistence

PostgreSQL

PostgreSQL is the recommended database backend for production deployments.

Basic Configuration

Managed Postgres Compatibility

Some hosted PostgreSQL platforms require additional configuration due to platform-specific restrictions.

SSL/TLS Support

To enable SSL for Postgres, add sslmode=require to your PostgreSQL connection URL:

The sslmode parameter controls TLS usage:

  • disable: Do not use TLS
  • prefer: Use TLS if available, otherwise connect without TLS (default)
  • require: Require TLS connection (fails if TLS is not available)

To verify the server certificate against a CA or verify the hostname, use custom SSL certificates (see below).

Custom SSL Certificates

For databases using custom certificate authorities (e.g., Supabase) or requiring client certificate authentication, you can specify certificate paths in the configuration:

ParameterDescriptionPostgreSQL Equivalent
root_cert_pathPath to the root certificate file for verifying the server’s certificatesslrootcert
client_cert_pathPath to the client certificate file for client certificate authenticationsslcert
client_key_pathPath to the client private key file for client certificate authenticationsslkey

All SSL paths are optional. If not specified, Rivet uses the default system root certificates from Mozilla’s root certificate store.

Do Not Use Connection Poolers

Rivet requires direct PostgreSQL connections for session-level features and does not support connection poolers.

Do not use:

  • PgBouncer
  • Supavisor
  • AWS RDS Proxy

Troubleshooting

Permission Denied Errors

If you see errors like:

ERROR: permission denied to set parameter "deadlock_timeout"
ERROR: current transaction is aborted, commands ignored until end of transaction block

Add unstable_disable_lock_customization: true to your configuration:

{
  "database": {
    "postgres": {
      "url": "postgresql://...",
      "unstable_disable_lock_customization": true
    }
  }
}
JSON

This disables Rivet’s attempt to set lock_timeout = 0 and deadlock_timeout = 10ms. Since lock_timeout defaults to 0 in PostgreSQL, skipping these settings is safe. Deadlock detection will use the default 1s timeout instead of 10ms.