> ## Documentation Index
> Fetch the complete documentation index at: https://vexidata.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL

> Connect your PostgreSQL database to VexiData.

<Tip>
  If you're using a managed PostgreSQL service, check our provider-specific guides for step-by-step instructions tailored to your platform:

  <CardGroup cols={3}>
    <Card title="Supabase" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/supabase.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=01f74d03d7dc9b7b772e6b27d612b9b0" href="/providers/supabase" width="16" height="16" data-path="images/data-source-connections/supabase.svg" />

    <Card title="Neon" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/neon.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=29938f159571465a85f54527fd3f377b" href="/providers/neon" width="16" height="16" data-path="images/data-source-connections/neon.svg" />

    <Card title="DigitalOcean" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/digitalocean.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=07bfe7f1cad6dc273fd311044deb076a" href="/providers/digital-ocean" width="16" height="16" data-path="images/data-source-connections/digitalocean.svg" />

    <Card title="AWS RDS" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/aws.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=ec0bac54f9403a756fcee3551b59afec" href="/providers/aws-rds" width="16" height="16" data-path="images/data-source-connections/aws.svg" />

    <Card title="Render" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/render.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=dd216e7c923e830e473de3a552efc0b1" href="/providers/render" width="16" height="16" data-path="images/data-source-connections/render.svg" />

    <Card title="Heroku" icon="https://mintcdn.com/mtsdigitalventuressrl/7jtPliLLIO4gCxrB/images/data-source-connections/heroku.svg?fit=max&auto=format&n=7jtPliLLIO4gCxrB&q=85&s=b21e860aececda6372e84399a5a04527" href="/providers/heroku" width="800" height="800" data-path="images/data-source-connections/heroku.svg" />

    <Card title="Railway" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/railway.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=db1ef351573f47dbb6137d719470b832" href="/providers/railway" width="16" height="16" data-path="images/data-source-connections/railway.svg" />

    <Card title="Laravel Cloud" icon="https://mintcdn.com/mtsdigitalventuressrl/CGk4Bkxy54XaDgd5/images/data-source-connections/laravel-cloud.svg?fit=max&auto=format&n=CGk4Bkxy54XaDgd5&q=85&s=8c77f90ac68c096ac1038c1bba5910c0" href="/providers/laravel-cloud" width="98" height="98" data-path="images/data-source-connections/laravel-cloud.svg" />

    <Card title="Google Cloud SQL" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/google-cloud-sql.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=6402c46f70abeb5c75640caac469d4dc" href="/providers/google-cloud-sql" width="512" height="512" data-path="images/data-source-connections/google-cloud-sql.svg" />

    <Card title="Azure Database" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/azure.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=cec7322fde2eb522ad6f0d2c4ed28622" href="/providers/azure-database" width="16" height="16" data-path="images/data-source-connections/azure.svg" />

    <Card title="Aiven" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/aiven.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=6fa81839f8196d019b6dafaeec94ce84" href="/providers/aiven" width="42" height="36" data-path="images/data-source-connections/aiven.svg" />

    <Card title="Fly.io" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/fly-io.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=edeb3204c5ba51f9bfd5137c4702fd88" href="/providers/fly-io" width="16" height="16" data-path="images/data-source-connections/fly-io.svg" />

    <Card title="Timescale" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/timescale.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=bcf9fe30176a6e32580b49a5da384b50" href="/providers/timescale" width="16" height="16" data-path="images/data-source-connections/timescale.svg" />

    <Card title="CockroachDB" icon="https://mintcdn.com/mtsdigitalventuressrl/9yUap0SLGrotT8se/images/data-source-connections/cockroachdb.svg?fit=max&auto=format&n=9yUap0SLGrotT8se&q=85&s=fed62c6b410aec5451a9deae3555c92a" href="/providers/cockroachdb" width="16" height="16" data-path="images/data-source-connections/cockroachdb.svg" />
  </CardGroup>
</Tip>

## Prerequisites

* A PostgreSQL database (version 12 or later recommended) that is accessible over the network
* The database host, port, name, username, and password
* A [VexiData](https://vexidata.com) account

## Connect PostgreSQL to VexiData

<Steps>
  <Step title="Gather your connection details">
    You need five pieces of information to connect. If you set up PostgreSQL yourself, you'll already know these. If someone else manages the database, ask your database administrator.

    | Parameter    | Description                                          | Default     |
    | ------------ | ---------------------------------------------------- | ----------- |
    | **Host**     | The hostname or IP address of your PostgreSQL server | `localhost` |
    | **Port**     | The port PostgreSQL is listening on                  | `5432`      |
    | **Database** | The name of the database you want to query           | `postgres`  |
    | **Username** | A PostgreSQL user with access to the database        | `postgres`  |
    | **Password** | The password for that user                           | —           |
  </Step>

  <Step title="Allow VexiData through your firewall (if applicable)">
    If your PostgreSQL server is behind a firewall or only accepts connections from specific IPs, add VexiData's IP addresses:

    * `46.101.71.122`

    **Common places to configure this:**

    * **Cloud VMs** (AWS EC2, DigitalOcean Droplets, GCP Compute) — Security Groups or firewall rules
    * **Self-hosted servers** — `pg_hba.conf` and/or your OS firewall (e.g., `ufw`, `iptables`)
    * **Managed databases** — See the provider-specific guides linked above

    <Info>
      If your database is only accessible from `localhost` or a private network, you'll need to either expose it to the internet or set up an SSH tunnel. VexiData requires a direct TCP connection to your database.
    </Info>
  </Step>

  <Step title="Verify PostgreSQL accepts remote connections">
    By default, PostgreSQL only listens on `localhost`. If your database is on a remote server, make sure it's configured to accept external connections:

    1. In `postgresql.conf`, set:

    ```
    listen_addresses = '*'
    ```

    2. In `pg_hba.conf`, add a line allowing VexiData's IPs (or all IPs if behind a firewall):

    ```
    host    all    all    46.101.71.122/32    scram-sha-256
    ```

    3. Restart PostgreSQL for changes to take effect.

    <Info>
      Managed database services (Supabase, Neon, RDS, etc.) handle this automatically. You only need this step for self-hosted PostgreSQL.
    </Info>
  </Step>

  <Step title="Add the connection in VexiData">
    1. Go to [Data Sources](https://vexidata.com/data-sources) in VexiData
    2. Click **PostgreSQL** to open the connection form
    3. Fill in the details:

    | Field            | Value                                                                |
    | ---------------- | -------------------------------------------------------------------- |
    | **Display Name** | A name to identify this connection (e.g., "Production DB")           |
    | **Host**         | Your server's hostname or IP address                                 |
    | **Port**         | `5432` (or your custom port)                                         |
    | **Database**     | Your database name                                                   |
    | **Schema**       | `public` (default — change if your tables are in a different schema) |
    | **Username**     | Your PostgreSQL username                                             |
    | **Password**     | Your PostgreSQL password                                             |
  </Step>

  <Step title="Test and save">
    Click **Test & Save Connection**. VexiData will verify it can reach your database. Once connected, your schema will be analyzed automatically.
  </Step>
</Steps>

## Creating a read-only user (recommended)

For security, we recommend connecting VexiData with a dedicated read-only user instead of your admin or application user. This ensures VexiData can only read data, never modify it.

```sql theme={null}
-- Create the user
CREATE USER vexidata WITH PASSWORD 'your-secure-password';

-- Grant connect access to the database
GRANT CONNECT ON DATABASE your_database TO vexidata;

-- Grant read access to the public schema
GRANT USAGE ON SCHEMA public TO vexidata;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO vexidata;

-- Ensure future tables are also readable
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO vexidata;
```

If your tables are in a **custom schema**, replace `public` with your schema name in the commands above.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Connection timed out">
    This means VexiData can't reach your server. Check:

    * Your firewall allows inbound connections on the PostgreSQL port from VexiData's IPs
    * `listen_addresses` in `postgresql.conf` is set to `'*'` (not `'localhost'`)
    * Your server has a public IP or hostname that resolves correctly
    * If on a cloud VM, the Security Group / firewall rules allow traffic on port `5432`
  </Accordion>

  <Accordion title="Authentication failed">
    * Verify the username and password are correct
    * Check `pg_hba.conf` allows the authentication method you're using (e.g., `scram-sha-256` or `md5`) for remote connections
    * Some setups use `peer` or `ident` authentication which only works for local connections — remote connections need password-based auth
  </Accordion>

  <Accordion title="Database does not exist">
    * PostgreSQL is case-sensitive for database names. Make sure the name matches exactly (e.g., `MyApp` is different from `myapp`)
    * Run `\l` in `psql` to list all available databases
  </Accordion>

  <Accordion title="No tables visible after connecting">
    * Confirm your tables are in the `public` schema. If they're in a custom schema (e.g., `app` or `api`), update the **Schema** field in VexiData
    * Check that your user has `SELECT` permissions: `GRANT SELECT ON ALL TABLES IN SCHEMA public TO your_user;`
  </Accordion>

  <Accordion title="SSL required / SSL connection errors">
    * If your server requires SSL, VexiData will attempt SSL automatically
    * For self-hosted servers, ensure your PostgreSQL SSL certificates are properly configured
    * Check that `ssl = on` is set in `postgresql.conf` if you require encrypted connections
  </Accordion>
</AccordionGroup>
