Skip to main content
This guide explains how to use pgstream with Neon databases, covering snapshots and replication. 👉 Throughout this guide:
  • pgstreamsource refers to the user provided in the pgstream source URL.
  • pgstreamtarget refers to the user provided in the pgstream target URL.

Snapshots

From Neon Database (Snapshots)

Quick Checklist

  • Create a source user (pgstreamsource) with access to required schemas/tables.
  • For roles without passwords → no special config needed.
  • For roles with passwords → must use the neondb_owner superuser.
  • Update YAML config with correct snapshot settings.

Steps

  1. User privileges Ensure the pgstreamsource user (from the pgstream source URL) owns the database schema and tables you want to snapshot.
  2. Roles handling
    • No roles → no changes required.
    • Roles without passwords → no changes required.
    • Roles with passwordsmust use the neondb_owner user.
    ⚠️ Only the neondb_owner user has access to the pg_authid table required for snapshotting roles with passwords. Without this, you’ll see:
  3. Config when not snapshotting roles If roles are disabled or not manually managed, add the following to avoid failures:
    Example full configuration:
ℹ️ Neon-managed roles (neondb_owner, neon_service, neon_superuser and cloud_admin) will not be snapshotted.

To Neon Database (Snapshots)

Quick Checklist

  • Create a target user (pgstreamtarget) for the pgstream target URL.
  • Grant privileges for schema/database ownership.
  • Grant optional privileges depending on features (create DB, create roles).
  • Use disable_triggers: false (required for all non-neon users).

Steps

The pgstreamtarget user (from the pgstream target URL) must have the following privileges:
  • Schema ownership
  • Database creation (if create_target_db is enabled)
  • Role creation (if roles_snapshot_mode is enabled/no_passwords)
    ⚠️ pgstreamtarget must already hold any privileges it assigns (e.g., REPLICATION).
  • Disable triggers (required for Neon) ⚠️ Not even the pseudo-superuser neondb_owner user can set session_replication_role on Neon databases.
    ❌ If using disable_triggers: true, pgstream will fail with:

Replication

From Neon Database (Replication)

Quick Checklist

  • Ensure logical replication is enabled on your Neon database.
  • Use the neondb_owner user for initialization (only user with event trigger privileges).
  • Optionally use a different pgstreamsource user for streaming.

Steps

  1. Enable logical replication Logical replication requires wal_level to be set to logical. Check current setting:
    If not set to logical, update it: Neon enables logical replication by default on most databases. If you see wal_level = replica, you can enable logical replication through the Neon Console:
    1. Go to your project in the Neon Console
    2. Navigate to SettingsReplication
    3. Enable Logical replication
    4. No restart is required - Neon handles this automatically
    Alternatively, you can enable it via the Neon API or contact Neon support.
  2. Replication phases
    • Initialization → requires elevated privileges to create schemas, event triggers, and replication slots.
    • Streaming → can use a dedicated pgstreamsource user.

Initialization

Initialization does the following:
  • Creates pgstream schema
  • Creates replication slot (if missing)
  • Creates event triggers/functions for schema changes
⚠️ Only the neondb_owner user has sufficient privileges to create event triggers. Use the neondb_owner user for initialization:

Streaming

After initialization, you can:
  • Keep using neondb_owner, or
  • Transfer ownership to a dedicated pgstreamsource role.

To Neon Database (Replication)

Quick Checklist

Steps

Privileges required:

Troubleshooting

Cause: Roles with passwords require pg_authid access.
Fix: Use neondb_owner user as source, or disable role passwords (roles_snapshot_mode: no_passwords).
Cause: No available Neon users can set this parameter.
Fix: Set disable_triggers: false in target config.
Cause: Target role lacks CREATE privilege on schema.
Fix: Grant CREATE on schema to the role: GRANT CREATE ON SCHEMA public TO role_name;
Cause: pgstreamtarget lacks privileges it tries to assign.
Fix: Grant required privileges to pgstreamtarget first, or use a user with more privileges.