Connection URLs (Prisma ORM v7) (/docs/orm/v7/reference/connection-urls)
For the complete Prisma documentation index, see llms.txt. A markdown version of any docs page is available by appending
.mdto its URL.
Learn about the format and syntax Prisma ORM uses for defining database connection URLs for PostgreSQL, MySQL and SQLite
Location: ORM > v7 > Reference > Connection URLs
Prisma ORM needs a connection URL to be able to connect to your database, e.g. when sending queries with Prisma Client or when changing the database schema with Prisma Migrate.
The connection URL is provided via the url field of a datasource block in your Prisma config (or Prisma schema if on version 6). It usually consists of the following components (except for SQLite and Prisma Postgres):
- 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
Make sure you have this information at hand when getting started with Prisma ORM. If you don't have a database server running yet, you can either use a local SQLite database file (see the Quickstart) or setup a free PostgreSQL database with Prisma Postgres.
Format
Section titled “Format”The format of the connection URL depends on the database connector you're using. Prisma ORM generally supports the standard formats for each database. You can find out more about the connection URL of your database on the dedicated docs page:
Special characters
Section titled “Special characters”For MySQL, PostgreSQL and CockroachDB you must percentage-encode special characters in any part of your connection URL - including passwords. For example, p@$$w0rd becomes p%40%24%24w0rd.
For Microsoft SQL Server, you must escape special characters in any part of your connection string.
Examples
Section titled “Examples”Here are examples for the connection URLs of the databases Prisma ORM supports:
Prisma Postgres
Section titled “Prisma Postgres”Prisma Postgres is a managed PostgreSQL service running on unikernels. There are several ways to connect to Prisma Postgres:
- via direct TCP connections (lets you connect via any ORM or database tool)
- via pooled TCP connections (recommended for serverless and high-concurrency workloads)
- via the hosted Prisma Accelerate connection (retiring December 1, 2026)
- locally
The connection string formats of these are covered below.
Direct TCP
Section titled “Direct TCP”When you connect to Prisma Postgres via direct TCP, your connection string looks as follows:
DATABASE_URL="postgres://USER:PASSWORD@db.prisma.io:5432/postgres?sslmode=require"The USER and PASSWORD values are provided when you generate credentials for your Prisma Postgres instance in the Prisma Console.
Pooled TCP
Section titled “Pooled TCP”When you connect to Prisma Postgres via pooled TCP, your connection string looks as follows:
DATABASE_URL="postgres://USER:PASSWORD@pooled.db.prisma.io:5432/?sslmode=require"Use a pooled TCP connection string for serverless, bursty, or high-concurrency workloads. Learn more in Connection pooling.
Via Prisma Accelerate (HTTP, retiring)
Section titled “Via Prisma Accelerate (HTTP, retiring)”[!WARNING] Hosted Accelerate connection retirement
The hosted
prisma+postgres://accelerate.prisma-data.netconnection ends on December 1, 2026. Existing Prisma Postgres customers should switch to pooled TCP or the Prisma Postgres serverless driver.This does not affect Local Postgres
prisma+postgres://localhostURLs.
When connecting via Prisma Accelerate, the connection string doesn't require a user/password like a conventional connection string does. Instead, authentication works via an API key:
export default defineConfig({
datasource: {
url: "prisma+postgres://accelerate.prisma-data.net/?api_key=API_KEY"
},
});In this snippet, API_KEY is a placeholder for the API key generated by the Prisma Console.
Local Prisma Postgres
Section titled “Local Prisma Postgres”The connection string for connecting to a local Prisma Postgres instance mirrors the structure of a remote instance via Accelerate:
export default defineConfig({
datasource: {
url: "prisma+postgres://localhost:51213/?api_key=__API_KEY__"
},
});However, in this case the API_KEY doesn't provide authentication details. Instead, it encodes information about the local Prisma Postgres instance. You can obtain a local connection string via the prisma dev command.
PostgreSQL
Section titled “PostgreSQL”export default defineConfig({
datasource: {
url: "postgresql://janedoe:mypassword@localhost:5432/mydb?schema=sample"
},
});export default defineConfig({
datasource: {
url: "mysql://janedoe:mypassword@localhost:3306/mydb"
},
});Microsoft SQL Server
Section titled “Microsoft SQL Server”export default defineConfig({
datasource: {
url: "sqlserver://localhost:1433;initial catalog=sample;user=sa;password=mypassword;"
},
});SQLite
Section titled “SQLite”export default defineConfig({
datasource: {
url: "file:./dev.db"
},
});CockroachDB
Section titled “CockroachDB”export default defineConfig({
datasource: {
url: "postgresql://janedoe:mypassword@localhost:26257/mydb?schema=public"
},
});MongoDB
Section titled “MongoDB”Support for MongoDB is limited to Prisma 6 as of now. We're working on support for MongoDB in Prisma v7
You can also provide the connection URL as an environment variable:
datasource db {
provider = "postgresql"
}You can then either set the environment variable in your terminal or by providing a dotenv file named .env. This will automatically be picked up by the Prisma CLI.
Prisma ORM reads the connection URL from the dotenv file in the following situations:
- When it updates the schema during build time
- When it connects to the database during run time
DATABASE_URL=postgresql://janedoe:mypassword@localhost:5432/mydbRelated pages
Section titled “Related pages”Config API: Complete reference for prisma.config.ts configuration optionsDatabase Features: Database features supported in Prisma ORMEnvironment Variables: Reference for Prisma environment variablesError Reference: Prisma Client, Migrate, and Introspection error codesPrisma CLI reference: This page gives an overview of all available Prisma CLI commands, explains their options and shows numerous usage examples