PostgreSQL on Render

Migrating from Heroku? We’re previewing an upcoming tool for low-downtime PostgreSQL migration and are looking for organizations with a large (50+ GB) Heroku Postgres database to migrate. We’ll work with selected organizations to help ensure a successful, speedy migration.

Apply for the preview.

Render offers fully managed PostgreSQL for encrypted, scalable storage and retrieval of relational data.

All paid PostgreSQL instances include daily backups (retained at least 7 days). Instances belonging to a Professional workspace or higher also include point-in-time recovery.

Quickstarts

These Render quickstarts include steps for provisioning a PostgreSQL database:

Create your database

  1. Go to dashboard.render.com/new/database, or select New > PostgreSQL from the Render Dashboard.

    This form appears:

    New PostgreSQL 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 12 through 16 are available for all new instances.
    • Version 11 is also available if the owning workspace has at least one existing database on version 11.
  6. Scroll down to select an instance type for your database:

    Learn about Free instance type limitations.

    Selecting a PostgreSQL instance type

    Note that you can upgrade an existing database to a larger instance type at any time, but you can’t downgrade to a smaller instance.

  7. Click Create Database.

Connect to your database

Every Render PostgreSQL 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
Render
Internal
URL
External
URL
Web
service
DB
Your dev machine
(admin tools, etc.)

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

Both URLs are available from the Connect menu in the top-right corner of your database’s page in the Render Dashboard:

The Connect menu for a Render PostgreSQL database

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 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).

Render uses the default PostgreSQL port 5432 to connect. You can usually leave this port unspecified.

Connecting with the internal URL

To use the internal URL, your connecting service and your database must belong to the same account and region.

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:

Top half of DB page showing hostname, username, database, password, and internal database URL

In addition to viewing the individual details, you can view the combined internal URL (of the format postgresql://USER:PASSWORD@INTERNAL_HOST:PORT/DATABASE). Use whichever format your framework expects for database credentials.

Connecting with the external URL

External URL connections are slower because they traverse the public internet. Always use the internal URL 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 in the Render Dashboard:

Bottom half of DB page showing the (hidden) external connection string and PSQL command

Most database clients understand the external URL, which has the 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.

If you encounter an SSL error, confirm that your PostgreSQL client supports TLS version 1.2 or higher, and that it supports any of the following cipher suites:


Click to show
  • 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

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

In the Render Dashboard, go to your database’s Info page and scroll down to the Access Control section:

Database Access Control Section

You can specify IP address blocks concisely using CIDR notation.

These rules apply to connections using your database’s external URL. Your Render services in the same region as your database can always connect using your database’s internal URL.

Connection limits

Your database’s maximum number of simultaneous connections depends on its instance type’s total memory (RAM):

MemoryMax Connections
<= 6GB97 connections
Between 6GB and 10GB197 connections
>= 10GB397 connections

If you’re approaching your connection limit, consider upgrading your instance type or implementing connection pooling.

All instances created before 11 August 2021 support a maximum of 97 connections, regardless of allocated memory. To schedule a configuration update to migrate to the connection limits listed above, please email support@render.com.

Adding multiple databases to a single instance

The simplest configuration used by most applications is to have a single database per PostgreSQL instance. However, Render also supports creating multiple databases in a single instance. You can create a new database inside your instance by connecting to it with psql and and using the CREATE DATABASE <name> command. You can connect to the newly created database the same way, postgresql://USER:PASSWORD@HOST:PORT/name. Make sure to use version psql >= 14.2 when connecting from outside Render.

Note: This feature is available by default on PostgreSQL instances created after October 30th 2022. If you’d like to create multiple databases in an instance created before October 30, 2022, please contact support with your database details so we can enable the feature on your instance.

Disk space

We offer PostgreSQL instance types ranging from 1 GB to 256 GB of storage per instance. The database storage limit applies to all storage the PostgreSQL database needs, including caches, indices, etc. Backup storage does not count against your instance type’s storage limit.

We can always work with you to provide a custom instance type; just email us at support@render.com.

Encryption

Render encrypts PostgreSQL databases at rest using AES-256 data encryption. This encryption applies to the primary and replica instances and all automated backups. Public access to your PostgreSQL databases is encrypted in transit using Render managed TLS certificates.

Metrics and logs

Dashboard

You can view database metrics any time in the Render Dashboard. We currently support the following metrics:

MetricDescription
MemoryThe amount of memory used
CPUThe amount of CPU used
StorageThe amount of disk space used
Active ConnectionsThe number of active connections

Datadog Postgres 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.

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:

PostgreSQL slow query log

Upgrading your instance type

You can update your instance type to a larger instance with more RAM, CPU, and Storage.

Your database will be unavailable during the upgrade.

Update PostgreSQL instance type

If you need an instance with more RAM, CPU, or storage than any offered instance type, please contact support for assistance creating a custom instance type.

Downgrading

It is not currently possible to downgrade an existing database’s instance type. When creating your database, make sure to pick the instance type that works best for you.

If you want to move to a smaller instance type, create a new instance and restore a backup of your existing instance to it.

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 from the Render Dashboard. Scroll down to the bottom of your database’s Info page and click Delete Database.

Additional topics

See articles on the following: