# Configure Postgres for real-time syncing

Prepare an external PostgreSQL database and connect it to Stripe Data Pipeline.

To use real-time sync, you must provide a PostgreSQL database that you own or manage. Stripe supports PostgreSQL databases from any provider, including AWS services such as Amazon RDS and Aurora, Supabase, Neon, and self-hosted deployments, as long as the database meets the requirements in this guide.

This guide explains how to configure your database’s schema, user permissions, network access, and SSL settings so Stripe Data Pipeline can connect and sync data. You retain ownership of the database and can query it directly, connect downstream analytics systems, and manage access.

## Configure your database 

### Use a supported PostgreSQL version 

Use PostgreSQL 13 or later. Supported versions might change.

### Size your database 

Your storage requirements depend on the number of tables you sync and the amount of data in your Stripe account. If you sync all available tables, plan for approximately 1 GB of database storage for every 100,000 charges your business has processed through Stripe. Actual storage usage can vary based on your account’s data.

Enable storage autoscaling if your database provider supports it. With autoscaling enabled, you can start with a smaller database and allow its storage capacity to increase as Stripe backfills and syncs your data.

### Configure authentication 

Use username and password authentication. This workflow doesn’t support IAM database authentication.

### Create a dedicated Stripe user 

Create a PostgreSQL user for Stripe that’s separate from your database administrator user. Don’t provide Stripe with your administrator username and password.

Grant the Stripe user `CONNECT` and `CREATE` permissions on the database. Stripe uses this user to create the schema that you specify in the Dashboard and to own and manage the tables in that schema.

Connect to the cluster as your database administrator, then run the following commands. Replace the placeholder values with your database name and a strong password.

```sql
CREATE USER stripe WITH LOGIN PASSWORD '{{STRIPE_PASSWORD}}';

GRANT CONNECT, CREATE ON DATABASE {{DATABASE_NAME}} TO stripe;
```

## Use a dedicated schema 

Use a separate schema for each pipeline, and don’t use Stripe-managed schemas for any other purpose.

If you sync data from multiple Stripe accounts to the same database, use Advanced setup to configure a different schema for each pipeline. We recommend using the corresponding Stripe account ID as each schema’s name. See [Connect your database in the Dashboard](https://docs.stripe.com/data/data-pipeline/real-time-sync-to-postgres/configure.md#connect-dashboard) for information about using Advanced setup.

## Recommended configurations 

Use the following network and SSL settings to secure connections from Stripe to your database.

### Allow incoming connections from Stripe 

To allow Stripe to connect to your database for live syncing, add the following IP addresses and ranges to your database’s inbound network rules, firewall allowlist, or access restrictions:

- `65.87.128.0/20`
- `3.18.12.63`
- `3.130.192.231`
- `13.235.14.237`
- `13.235.122.149`
- `18.211.135.69`
- `35.154.171.200`
- `52.15.183.38`
- `54.88.130.119`
- `54.88.130.237`
- `54.187.174.169`
- `54.187.205.235`
- `54.187.216.72`
- `35.157.207.129`
- `3.69.109.8`
- `3.120.168.93`

Stripe might use any of these addresses when connecting to your database. Make sure your network configuration permits inbound connections from every address in this list.

### Connect using SSL 

Stripe connects to your database using SSL. We recommend configuring your database connection to verify both the server hostname and certificate. You can provide the certificate in the Advanced setup, as shown in [Connect your database in the Dashboard](https://docs.stripe.com/data/data-pipeline/real-time-sync-to-postgres/configure.md#connect-dashboard).

## Connect your database in the Dashboard 

1. Go to the [Pipelines](https://dashboard.stripe.com/data-management/pipelines) page in the Stripe Dashboard.

2. Configure the connection using one of the following options. Use the [dedicated Stripe user](https://docs.stripe.com/data/data-pipeline/real-time-sync-to-postgres/configure.md#user-permissions) that you created earlier.

   - **Connection string**: Enter your complete database connection string with `sslmode=require` to require an encrypted connection. To verify the server hostname and certificate as recommended, use Advanced setup instead.

     ```text
     postgresql://stripe:{{STRIPE_PASSWORD}}@{{HOST}}:5432/{{DATABASE_NAME}}?sslmode=require
     ```

   - **Advanced setup**: Turn on **Advanced** to enter the host, port, username, password, database, and schema separately. To verify the server hostname and certificate, select **Verify certificate and server name**, then provide the CA certificate. You can also specify a custom schema.

3. Select the tables to sync to your database.

4. Click **Create pipeline**.

## What Stripe configures 

After Stripe confirms connectivity, it automatically:

- Creates the schema with the name that you specify in the Dashboard. If you use a connection string, Stripe uses the default schema name `stripe`.
- Creates and manages a table for each enabled sync object, such as charges, customers, and payment intents.
- Backfills the selected tables and then syncs changes from your Stripe account on a near-real-time basis.

Don’t modify or drop Stripe-managed schemas or tables. You can run read-only queries and connect analytics tools to these tables, but external writes can cause sync errors and data inconsistencies.
