# Create and Connect to Render Postgres


> *Migrating a large database from Heroku?*
>
> The Render team can help you orchestrate your migration to minimize downtime, even for apps with multi-terabyte databases.

Render Postgres databases provide fully managed, scalable storage of relational data.

All paid Render Postgres databases provide [point-in-time recovery](postgresql-backups) and on-demand logical exports. Larger instances support [read replicas](postgresql-read-replicas) and [high availability](postgresql-high-availability) for improved performance and reliability.

## Quickstarts

Here are a few Render quickstarts that include a Render Postgres database as part of their application stack:

- [Django](/deploy-django)
- [Rails](/deploy-rails-8)
- [Phoenix](/deploy-phoenix-distillery)

## Create your database

**Tab: Dashboard**

1. Go to [dashboard.render.com/new/database](https://dashboard.render.com/new/database), or click *+ New > Postgres* in the Render Dashboard.

   This form appears:

   [image: New Postgres creation form]

2. Provide a helpful *Name* for your database.
   - You can change this value at any time.
3. Optionally fill in the *Database* and/or *User* fields if you want to set your PostgreSQL `dbname` and/or username.
   - Render generates values for either of these that you don't specify.
   - You _can't_ change these values after creating your database.
4. Choose a *Region* to run your database in.
   - Choose the same region as your services that will connect to the database. This minimizes latency and enables communication over your private network.
5. Optionally change the *PostgreSQL Version* if you want to use an older version.
   - Major versions 13 through 18 are available for all new instances.
   - Versions 11 and 12 are available for workspaces that have at least one _existing_ database on the corresponding version.
6. Scroll down and select a *compute plan* for your database. This determines its available CPU and RAM.

> [Learn about limitations of the Free compute plan](free#free-postgres).

   [image: Selecting a Postgres compute plan]

   You can [change your compute plan](#changing-your-compute-plan) later.

7. Scroll down and set your database's initial storage, in GB.

   - You can specify 1 GB or any multiple of 5 GB.
   - You can increase your storage later, but you can't decrease it.

8. Optionally enable *Storage Autoscaling*.

   - Whenever your database is 90% full, Render automatically increases its storage by 50%, rounded up to the nearest multiple of 5 GB. You can't reduce storage after increasing it. [Learn more](#storage-autoscaling).

9. Click *Create Database*.

You're all set! Your new database's status updates to *Available* in the Render Dashboard when it's ready to use.

**Tab: CLI**

#### 1. Install the CLI

Use any of the following methods to install the Render CLI or upgrade to the latest version:

**Subtab: Homebrew**

##### Homebrew installation

Run the following commands:

```shell
brew update
brew install render
```

**Subtab: WinGet**

##### WinGet installation

Run the following command:

```shell
winget install render.cli
```

**Subtab: curl**

##### Installing with `curl`

Run the following command:

```shell
curl -fsSL https://raw.githubusercontent.com/render-oss/cli/refs/heads/main/bin/install.sh | sh
```

**Subtab: Direct download**

##### Direct download

1. Open the CLI's [GitHub releases page](https://github.com/render-oss/cli/releases/).
2. Download the executable that corresponds to your system's architecture.

If you use an architecture besides those provided, you can build from source instead.

**Subtab: Build from source**

##### Building from source

> We recommend building from source only if no other installation method works for your system.

1. [Install the Go programming language](https://golang.org/doc/install) if you haven't already.

2. Clone and build the CLI project with the following commands:

   ```shell
   git clone git@github.com:render-oss/cli.git
   cd cli
   go build -o render
   ```

After installation completes, open a new terminal tab and run `render` with no arguments to confirm.

#### 2. Create your database

Run `render pg create` to walk through an interactive wizard:

```shell
render pg create
```

To skip the wizard, provide flags directly. For example:

```shell
render pg create \
  --name my-database \
  --region oregon \
  --version 17 \
  --plan pro_4gb \
  --disk-size-gb 25 \
  --confirm
```

Supply the following options to configure your database:

------

##### `--name`

A name for your database. You can change this value at any time.

##### `--database-name`

Optionally set the PostgreSQL `dbname`. Render generates a value if you don't specify one.

You _can't_ change this value after creating your database.

##### `--database-user`

Optionally set the PostgreSQL username. Render generates a value if you don't specify one.

You _can't_ change this value after creating your database.

##### `--region`

The region to create the database in.

Choose the same region as your connecting services to minimize latency and enable communication over your private network.

##### `--version`

Optionally specify a PostgreSQL version. Defaults to the latest supported version (18).

- Major versions 13 through 18 are available for all new instances.
- Versions 11 and 12 are available for workspaces that have at least one _existing_ database on the corresponding version.

##### `--plan`

Specify a [compute plan](compute-plans?tab=postgres#all-plans) to determine your database's available RAM, CPU, and connection limit.

> [Learn about Free compute plan limitations](free#free-postgres).

##### `--disk-size-gb`

Set your database's initial storage in GB.

- You can specify 1 GB or any multiple of 5 GB.
- You can increase your storage later, but you _can't_ decrease it.

##### `--disk-autoscaling`

Optionally enable [storage autoscaling](#storage-autoscaling).

------

For the full list of options, see the [`pg create` reference](cli-reference#pg-create).

You're all set! After successfully running the command, the Render CLI returns your new database's details.

**Tab: API**

Using the [Render API](api), make a request to the [Create Postgres instance](https://api-docs.render.com/reference/create-postgres) endpoint.

## Connect to your database

Every Render Postgres database has two different URLs for incoming connections:

- An *internal URL* for connections from your other Render services hosted in the _same region_
- An *external URL* for connections from _everything else_

```mermaid
flowchart LR
    pgadmin("Your dev machine<br/>(admin tools, etc.)");
    subgraph "<b>Render</b>"
    webservice("Web<br/>service");
    database[("DB")];
    webservice edge1@-->|"Internal<br/>URL"|database;
    end
    pgadmin edge2@--->|"External<br/>URL"|database;
    edge1@{animation: slow}
    edge2@{animation: slow}
    class pgadmin secondary;
```

*Use the internal URL wherever possible.* It minimizes query latency by enabling communication over your private network.

**Tab: Dashboard**

Both URLs are available from the *Connect* menu in the top-right corner of your database's page in the [Render Dashboard](https://dashboard.render.com):

[image: The Connect menu for a Render Postgres database]

**Tab: CLI**

You can fetch your database's connection details and credentials using `render pg get` with the `--include-sensitive-connection-info` flag:

```shell
render pg get my-database --include-sensitive-connection-info
```

For more options, see the [`pg get` reference](cli-reference#pg-get).

**Tab: API**

Use the [Retrieve Postgres connection info](https://api-docs.render.com/reference/retrieve-postgres-connection-info) API endpoint to retrieve your database's connection details.

How you connect to your database depends on your code: some frameworks expect a single connection string or URL in an environment variable, while others need multiple connection parameters in a configuration file. See [Quickstarts](#quickstarts) for examples.

At a minimum, your app needs to know your database's hostname, port, username, password, and database name (such as `mydb` in the [official PostgreSQL tutorial](https://www.postgresql.org/docs/current/tutorial-createdb.html)).

> Render Postgres uses the default PostgreSQL port `5432`. You can usually leave this port unspecified.

### Internal connections

> To use the internal URL, your connecting service and your database must belong to the same account and [region](regions).

Wherever possible, connect to your database using its internal URL. Internal connection details are available on your database's *Info* page in the [Render Dashboard](https://dashboard.render.com):

[image: PostgreSQL private connection details in the Render Dashboard]

You can view both individual details and the assembled internal URL, which has the following format:

```
postgresql://USER:PASSWORD@INTERNAL_HOST:PORT/DATABASE
```

Use whichever format your framework expects for database credentials.

#### SSL modes for internal connections

Internal connections optionally support TLS using self-signed certificates.

Because these certificates are self-signed, internal connections do not support `sslmode=verify-ca` or `sslmode=verify-full`. To require TLS and prevent plaintext fallback, set `sslmode=require`.

For more details on `sslmode`, see the [PostgreSQL documentation](https://www.postgresql.org/docs/current/libpq-ssl.html).

### External connections

> *External URL connections are slower because they traverse the public internet.*
>
> To minimize latency, use your database's [internal URL](#internal-connections) when connecting from a Render service running in the same region.

Tools and systems outside of Render can connect to your database via its external URL, available from its *Info* page in the [Render Dashboard](https://dashboard.render.com):

[image: PostgreSQL public connection details in the Render Dashboard]

Most database clients understand the external URL, which has the following format:

```
postgresql://USER:PASSWORD@EXTERNAL_HOST:PORT/DATABASE
```

You can also run the provided *PSQL Command* directly in your terminal to start a psql session.

External connections to your database are always encrypted in transit using Render-managed TLS certificates. Render rejects external connections that set `sslmode=disable`. Set `sslmode=require` to require TLS.

#### Common external connection issues

###### &quot;FATAL:  No SNI information found&quot;

Make sure your PostgreSQL client always connects using your database's full external connection URL, _not_ an IP address that the hostname resolved to during a previous connection attempt.

###### TLS handshake errors

Confirm that your PostgreSQL client supports TLS version 1.2 or higher, and that it supports any of the following cipher suites:

- `TLS_AES_128_GCM_SHA256`
- `TLS_AES_256_GCM_SHA384`
- `TLS_CHACHA20_POLY1305_SHA256`
- `TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256`
- `TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256`
- `TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384`

### Restricting external access

> *These rules apply only to connections that use your database's [*external URL*](#external-connections).*
>
> Your Render services in the same region as your database can always connect using your database's [internal URL](#internal-connections).

By default, your Render Postgres instance is accessible from any IP address (if the connection uses valid credentials). You can modify this default behavior by restricting access to a set of IPs or even disabling external access entirely.

**Tab: Dashboard**

In the [Render Dashboard](https://dashboard.render.com), go to your database's *Info* page and scroll down to the *Networking* section:

[image: Setting PostgreSQL access control in the Render Dashboard]

You can specify IP address blocks using [CIDR notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_blocks). The default block is `0.0.0.0/0`, which allows access from any IP address.

**Tab: CLI**

Set your database's IP allow list using the `render pg update` command with the `--ip-allow-list` flag:

```shell
render pg update my-database \
  --ip-allow-list "cidr=203.0.113.5/32,description=office" \
  --ip-allow-list "cidr=10.0.0.0/8,description=internal"
```

> *Passing `--ip-allow-list` to this command _replaces_ your database's existing IP allow list.*
>
> Make sure to include _all_ address blocks you want to allow, including any existing blocks.

- Repeat the flag for each address block you want to allow.
- Provide IP address blocks in [CIDR notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_blocks).

To completely disable external access to your database, use the `--clear-ip-allow-list` flag:

```shell
render pg update my-database --clear-ip-allow-list
```

For more options, see the [`pg update` reference](cli-reference#pg-update).

**Tab: API**

Use the [Update Postgres instance](https://api-docs.render.com/reference/update-postgres/) API endpoint. Provide IP address blocks in [CIDR notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_blocks) in the `ipAllowList` parameter.

### Connection limits

Your database's maximum number of simultaneous connections depends on its compute plan's total memory (RAM):

| Memory | Max Connections |
| --- | --- |
| < 8 GB | 100 connections |
| 8 GB <= memory < 16 GB | 200 connections |
| 16 GB <= memory < 32 GB | 400 connections |
| \>= 32 GB | 500 connections |

If you're approaching your connection limit, consider [upgrading your compute plan](#changing-your-compute-plan) or implementing [connection pooling](postgresql-connection-pooling).

> *Databases on a [*legacy instance type*](postgresql-legacy-instance-types) support fewer connections:*
>
>
>
> | Memory | Max Connections |
> | --- | --- |
> | \<= 6 GB | 97 connections |
> | Between 6 GB and 10 GB | 197 connections |
> | \>= 10 GB | 397 connections |
>
>
>
> You can move your database to a flexible plan by [changing its compute plan](#changing-your-compute-plan).

## Adding storage

You set your database's initial storage during [creation](#create-your-database). Any time after that, you can increase your database's storage to any higher multiple of 5 GB, up to 16 TB.

> *Need more than 16 TB of storage?*
>
> Please [contact support](https://dashboard.render.com?contact-support) in the Render Dashboard.

You can increase storage [automatically](#storage-autoscaling) or [manually](#increasing-storage-manually).

*Note the following:*

- After you increase a database's storage, you can't increase it again for 6 hours.
- It is not possible to reduce a database's storage.
- Databases on a [legacy instance type](postgresql-legacy-instance-types) have a fixed storage capacity.
  - You can move your database to a flexible plan by [changing its compute plan](#changing-your-compute-plan).

### Storage autoscaling

You can automatically add storage to your database whenever it's running low. With *storage autoscaling* enabled, Render detects when your database is 90% full and permanently increases its storage by 50%, rounded up to the nearest multiple of 5 GB.

Here are some example increases:

| Original Storage | New Storage |
| --- | --- |
| 1 GB | 5 GB |
| 10 GB | 15 GB |
| 25 GB | 40 GB |

Enable storage autoscaling with any of the following methods:

**Tab: Dashboard**

#### Dashboard

1. From your database's *Info* page in the [Render Dashboard](https://dashboard.render.com), scroll down to the *PostgreSQL Instance* section and click *Update*:

   [image: Update PostgreSQL storage in the Render Dashboard]

2. Scroll down to the *Enable Storage Autoscaling* field and toggle the switch.

3. Click *Save Changes*.

**Tab: CLI**

#### CLI

Enable storage autoscaling using the `render pg update` command with the `--disk-autoscaling` flag:

```shell
render pg update my-database --disk-autoscaling
```

To disable autoscaling:

```shell
render pg update my-database --disk-autoscaling=false
```

For more options, see the [`pg update` reference](cli-reference#pg-update).

**Tab: API**

#### API

Use the [Update Postgres instance](https://api-docs.render.com/reference/update-postgres/) API endpoint. Set the `enableDiskAutoscaling` parameter to `true`.

That's it! Render will automatically add storage to your database whenever it's 90% full.

### Increasing storage manually

Manually add storage to your database with any of the following methods:

**Tab: Dashboard**

#### Dashboard

1. From your database's *Info* page in the [Render Dashboard](https://dashboard.render.com), scroll down to the *PostgreSQL Instance* section and click *Update*:

   [image: Update PostgreSQL storage in the Render Dashboard]

2. Scroll down to the *Storage* field and provide a new value.

   - Provide any multiple of 5 GB greater than the current storage capacity.

3. Click *Save Changes*.

That's it! The additional storage becomes available within a minute or two.

**Tab: CLI**

#### CLI

Increase your database's storage using the `render pg update` command with the `--disk-size-gb` flag:

```shell
render pg update my-database --disk-size-gb 50
```

Provide any multiple of 5 GB greater than the current storage capacity.

For more options, see the [`pg update` reference](cli-reference#pg-update).

**Tab: API**

#### API

Use the [Update Postgres instance](https://api-docs.render.com/reference/update-postgres/) API endpoint. Provide the new value in the `diskSizeGB` parameter.

Provide any multiple of 5 GB greater than the current storage capacity.

### Running out of storage

*If your database exceeds its storage limit, it becomes unhealthy.* Render automatically suspends the database to prevent data loss or other unexpected behavior.

To restore your database:

1. In the [Render Dashboard](https://dashboard.render.com), scroll to the bottom of your database's *Info* page and click *Resume Database*.

2. Wait a minute or two for the database to finish resuming.

3. Follow the steps to [manually add storage capacity](#increasing-storage-manually).
   - If you wait too long after resuming, Render will suspend your database again. In this case, return to step 1.

Your database will become healthy within a few minutes.

## Changing your compute plan

You can change your Render Postgres database's compute plan, which determines its available CPU and RAM. [View available compute plans](compute-plans?tab=postgres#all-plans).

> *Your database will be unavailable temporarily during the change.*
>
> - With [high availability](postgresql-high-availability) enabled, your database is unavailable for only a few seconds.
> - Otherwise, it's unavailable for a few minutes.
>
> Schedule your change during off hours to minimize user impact.

**Tab: Dashboard**

1. From your database's *Info* page in the [Render Dashboard](https://dashboard.render.com), scroll down to the *PostgreSQL Instance* section and click *Update*:

   [image: Update Postgres compute plan in the Render Dashboard]

2. Under *Plan Options*, select a new *Compute Plan*.

   - If your database currently uses a [legacy instance type](postgresql-legacy-instance-types), you won't be able to move _back_ to a legacy instance type after changing.

3. Click *Save Changes*.

That's it! Your new instance will be available within a few minutes.

**Tab: CLI**

Change your database's compute plan using the `render pg update` command with the `--plan` flag:

```shell
render pg update my-database --plan pro_8gb
```

If your database currently uses a [legacy instance type](postgresql-legacy-instance-types), you won't be able to move back to a legacy instance type after changing.

For more options, see the [`pg update` reference](cli-reference#pg-update).

**Tab: API**

Use the [Update Postgres instance](https://api-docs.render.com/reference/update-postgres/) API endpoint. Provide the new plan in the `plan` parameter.

If your database currently uses a [legacy instance type](postgresql-legacy-instance-types), you won't be able to move back to a legacy instance type after changing.

## Adding multiple databases to a single instance

You can create additional databases in your Render Postgres instance with the following steps:

1. In your terminal, open a psql session to your instance using the *PSQL Command* provided in the [Render Dashboard](https://dashboard.render.com):

   [image: Postgres public connection details in the Render Dashboard]

2. Run `CREATE DATABASE <name>`, providing the name for your new database.

You're all set! Use your instance's same internal and external URLs to connect, except substitute your new database's name as the final component:

```
postgresql://USER:PASSWORD@INTERNAL_HOST:PORT/DATABASE
```

## Encryption

Render Postgres databases are encrypted at rest using AES-256 data encryption. This encryption applies to both primary and replica instances, along with all backups.

- [External connections](#external-connections) to your database are always encrypted using Render-managed TLS certificates.
- [Internal connections](#internal-connections) optionally support TLS encryption using self-signed certificates.

## Metrics and logs

### Dashboard

View a variety of metrics for your database (disk usage, active connections, etc.) from its *Metrics* page in the [Render Dashboard](https://dashboard.render.com):

[image: Postgres metrics in the Render Dashboard]

For details, see [Service Metrics](service-metrics#available-metrics).

### Datadog

The Datadog integration provides additional metrics related to your PostgreSQL instance's host and disk. You can also use the Datadog UI to create dashboards and alerts for your database.

For details, see the [Datadog integration docs](datadog#setting-up-postgres-monitoring).

### Viewing slow query logs

Queries that take longer than 2 seconds are logged with a line that starts with `duration:` followed by the SQL statement. Here's an example:

[image: Postgres slow query log]

## Deleting your database

> *Render does not retain backups or snapshots of a deleted database instance!*
>
> Make sure to download any necessary backups before deleting your database.

You can delete a database instance in the [Render Dashboard](https://dashboard.render.com). Scroll down to the bottom of your database's *Info* page and click *Delete Database*.

## Additional topics

See articles on the following:

- [Recovery and backups](postgresql-backups)
- [Read replicas](postgresql-read-replicas)
- [High availability](postgresql-high-availability)
- [Upgrading your PostgreSQL version](postgresql-upgrading)
- [Connection pooling](postgresql-connection-pooling)
- [Render Postgres extensions](postgresql-extensions)
- [Performance troubleshooting](postgresql-performance-troubleshooting)

---

##### Appendix: Glossary definitions

###### region

Each Render service runs in one of the following regions: *Oregon*, *Ohio*, *Virginia*, *Frankfurt*, or *Singapore*.

Services in the same region can communicate over their *private network*.

Related article: https://render.com/docs/regions.md

###### private network

Your Render services in the same *region* can reach each other without traversing the public internet, enabling faster and safer communication.

Related article: https://render.com/docs/private-network.md