Skip to main content

Quick connect

Copy your connection string from the dashboard and use it directly:
pip install psycopg2-binary
import psycopg2

conn = psycopg2.connect("postgresql://user:[email protected]:5432/mydb?sslmode=require")
cur = conn.cursor()
cur.execute("SELECT 1")
print(cur.fetchone())
conn.close()

Connection details

Find your connection credentials in the Rivestack dashboard under the Connection tab of your database or cluster.
ParameterDescriptionExample
HostYour unique endpointrs-abc12345.eu-central.db.rivestack.io
PortPostgreSQL port5432
DatabaseDatabase namemydb
UsernameDatabase usermyuser
PasswordUser password(from dashboard)
SSL ModeAlways requiredrequire

Connection string

postgresql://username:password@host:5432/dbname?sslmode=require
Click the copy button next to each field in the dashboard to copy values to your clipboard.

SSL / TLS

All Rivestack connections require SSL. Unencrypted connections are rejected. Set sslmode=require in your connection string or driver configuration. No CA certificate download is needed — Rivestack uses certificates signed by a trusted public CA.

Connect with psql

psql "host=rs-abc12345.eu-central.db.rivestack.io port=5432 dbname=mydb user=myuser sslmode=require"
You’ll be prompted for your password. To include it inline:
psql "postgresql://myuser:[email protected]:5432/mydb?sslmode=require"

Language examples

Using psycopg2

pip install psycopg2-binary
import psycopg2

conn = psycopg2.connect(
    host="rs-abc12345.eu-central.db.rivestack.io",
    port=5432,
    dbname="mydb",
    user="myuser",
    password="mypassword",
    sslmode="require"
)

cur = conn.cursor()
cur.execute("SELECT version()")
print(cur.fetchone())

cur.close()
conn.close()

Using SQLAlchemy

pip install sqlalchemy psycopg2-binary
from sqlalchemy import create_engine

engine = create_engine(
    "postgresql://myuser:[email protected]:5432/mydb",
    connect_args={"sslmode": "require"}
)

with engine.connect() as conn:
    result = conn.execute("SELECT version()")
    print(result.fetchone())

HA cluster connections

For HA clusters, connections are routed through a load balancer that automatically directs traffic to the primary node.
PortTarget
5432Primary (read-write)
5001Replicas (read-only)
5002Synchronous replicas
5003Asynchronous replicas
For most applications, connect to port 5432. The load balancer handles failover automatically — your application reconnects to the new primary without changing connection details.

Connection limits

TierMax Connections
Free5
HA Cluster100

Troubleshooting

  • Verify your host, port, and credentials are correct.
  • Ensure you’re using sslmode=require.
  • Check that your host and port are correct.
All connections require SSL. Make sure your client is configured with sslmode=require. You do not need to download a CA certificate.
Free tier databases are limited to 5 connections. HA clusters support up to 100. Close idle connections or use connection pooling in your application.