Powering next gen AI apps with Postgres 🚀 Learn More

Use Prisma Migrate with Neon

Learn how to use Prisma Migrate with Neon

This topic also describes how to configure Prisma Migrate when you need to connect to the same Neon database from Prisma Migrate, which requires a direct database connection, and serverless functions that require a pooled database connection.

Prisma Migrate with PgBouncer

Prisma Migrate requires a direct connection to the database. It does not support connection pooling with PgBouncer. Attempting to run Prisma Migrate commands, such as prisma migrate dev, with a pooled connection causes the following error:

To avoid this issue, ensure that you are using a direct connection to the database for Prisma Migrate. Neon supports both pooled and direct connections to the same database. See Enable connection pooling for more information.

You can configure Prisma Migrate to use a direct connection while allowing applications to use Prisma Client with a pooled connection by adding a directUrl property to the datasource block in your schema.prisma file. For example:


The directUrl property is available in Prisma version 4.10.0 and higher.

After adding the directUrl property to your schema.prisma file, update the DATABASE_URL and DIRECT_URL variables settings in your .env file:

  1. Set DATABASE_URL to the pooled connection string for your Neon database. Applications that require a pooled connection should use this connection.
  2. Set DIRECT_URL to the direct (non-pooled) connection string. This is the direct connection to the database required by Prisma Migrate.

When you are finished updating your .env file, your variable settings should appear similar to the following:

Edit this page
Was this page helpful?