Back to Prisma

Direct connections

apps/docs/content/docs/postgres/database/direct-connections.mdx

latest4.4 KB
Original Source

Overview

Prisma Postgres supports both direct and pooled TCP connections, whether you connect to it via Prisma ORM or any other ORM, database library / tool of your choice. This page covers the direct, non-pooled connection string. For pooled TCP connections, see Connection pooling.

How to connect to Prisma Postgres via direct TCP

In order to get a direct connection string, you need to:

  1. Open a project in your Prisma Console account (or create a new one)
  2. Navigate to your active Prisma Postgres instance.
  3. Click the Connect to your database button in your dashboard.
  4. Click the Generate new connection string button.
  5. Copy the direct connection string that is generated below.

Connection string

Format

When you connect to Prisma Postgres via direct TCP, your connection string looks as follows:

bash
DATABASE_URL="postgres://USER:PASSWORD@HOST:PORT/DATABASE_NAME?sslmode=require"

This is built up from the following parts:

  • User: The name of your database user
  • Password: The password for your database user
  • Host: The IP or domain name of the machine where your database server is running
  • Port: The port on which your database server is running
  • Database name: The name of the database you want to use

The USER and PASSWORD values are provided when you generate credentials for your Prisma Postgres instance in the Prisma Console. Here is an example with sample values:

bash
DATABASE_URL="postgres://2f9881cc7eef46f094ac913df34c1fb441502fe66cbe28cc48998d4e6b20336b:[email protected]:5432/?sslmode=require"

SSL mode

SSL mode is required when connecting to Prisma Postgres via direct TCP, so you need to append sslmode=require to your TCP connection string.

Billing

When using direct TCP to connect to a Prisma Postgres instance, every request is counted as a billable operation. Learn more on our pricing page.

Temporary limitations

Closing idle connections

Prisma Postgres closes idle connections after an extended period of time. If that happens in your application, you can re-open a new connection. (Most database clients re-connect automatically.)

Connection limit

FreeStarterProBusiness
Connection limitMax 10Max 10Max 50Max 100

Query and transaction timeouts

FreeStarterProBusiness
Query timeoutUp to 10 secondsUp to 10 secondsUp to 10 secondsUp to 10 seconds
Interactive transactions timeoutUp to 15 secondsUp to 15 secondsUp to 15 secondsUp to 15 seconds

Limited user permissions

User permissions are limited to read, write and schema changes. It is not possible to create separate databases, manage users and roles, or perform other administrative actions.

TCP tunnel (deprecated)

:::warning

The TCP tunnel feature has been deprecated in favor of direct connections. Please use direct connections for all new integrations and migrate existing implementations.

:::

Use your direct TCP connection string with your preferred PostgreSQL client or tooling. Common options include:

For step-by-step examples of connecting with database editors, see Viewing data in Prisma Postgres.