Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4133 pages
Node.js, PHP and APIs

new PrismaClient() throws as soon as the app starts after moving to Prisma ORM 7

Your error

PrismaClientInitializationError: PrismaClient was instantiated without any options. A driver adapter is required to connect to your database.4 more lines it can show

Fix it fast

Most common cause, 1 of 3

The client is created with no options

Install the adapter for your database and hand it to the constructor.

Fix
npm install @prisma/adapter-pg@7

// src/db.ts
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from '../generated/prisma/client'

const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
export const prisma = new PrismaClient({ adapter })
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Prisma ORM 7 dropped the built-in connection: the client generated by the prisma-client provider talks to the database only through a driver adapter. new PrismaClient() with no options, or with the v6 datasourceUrl or datasources options, therefore fails at startup. Install the adapter for your database, for example @prisma/adapter-pg, and pass it as { adapter }.

  • Applies to Prisma ORM 7.0.0, Prisma ORM 7.10, Node.js 24, TypeScript 7.0
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Confirm the installed version and find every place the client is created. The fix is the same for all of them.

Run this first
npx prisma --version
grep -rn "new PrismaClient(" src app lib 2>/dev/null

Then find the line you see in this list and open its fix:

  1. 1The client is created with no optionsOn 7.10 the message says a driver adapter is required; on 7.0.0 the same code fails with a TypeError about __internal
  2. 2The v6 connection options are still passedUnknown property datasourceUrl (or datasources) provided to PrismaClient constructor
  3. 3The project connects through Prisma AccelerateDATABASE_URL starts with prisma:// or prisma+postgres://

What does the error look like?

  • PrismaClientInitializationError: PrismaClient was instantiated without any options. A driver adapter is required to connect to your database.
  • PrismaClientConstructorValidationError: Using engine type "client" requires either "adapter" or "accelerateUrl" to be provided to PrismaClient constructor.
  • TypeError: Cannot read properties of undefined (reading '__internal')
  • PrismaClientConstructorValidationError: Unknown property datasourceUrl provided to PrismaClient constructor.
  • error TS2554: Expected 1 arguments, but got 0.

Cause 1 of 3

The client is created with no options

You seeOn 7.10 the message says a driver adapter is required; on 7.0.0 the same code fails with a TypeError about __internal

Check

The upgrade guide states that creating a Prisma Client now requires a driver adapter for every database. Old code that called new PrismaClient() with nothing in the brackets has no way to reach the database any more, and TypeScript also flags the missing argument.

Check
grep -rn "new PrismaClient()" .

Fix

Install the adapter for your database and hand it to the constructor. PostgreSQL uses @prisma/adapter-pg, SQLite uses @prisma/adapter-better-sqlite3; the database drivers page lists the others.

Fix
npm install @prisma/adapter-pg@7

// src/db.ts
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from '../generated/prisma/client'

const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
export const prisma = new PrismaClient({ adapter })

Verify

Start the app or run a script that imports the client; it constructs without throwing and the first query reaches the database.

Verify
// scripts/check-db.ts
import { prisma } from '../src/db'
prisma.$queryRaw`SELECT 1`.then(console.log).finally(() => prisma.$disconnect())

npx tsx scripts/check-db.ts

Confirmed by prisma.io

Did this fix it?

Cause 2 of 3

The v6 connection options are still passed

You seeUnknown property datasourceUrl (or datasources) provided to PrismaClient constructor

Check

Version 6 let you override the URL with datasourceUrl or datasources.db.url. In 7 the constructor validates its options and rejects those keys, because the connection string now belongs to the adapter.

Check
grep -rnE "datasourceUrl|datasources:" src app lib

Fix

Delete those keys and give the same URL to the adapter instead. The CLI side (migrate, db push) reads the URL from prisma.config.ts, so keep it there too.

Fix
// before (v6)
// const prisma = new PrismaClient({ datasourceUrl: process.env.DATABASE_URL })

// after (v7)
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter })

Verify

TypeScript compiles the file and the constructor no longer reports an unknown property.

Verify
npx tsc --noEmit

Confirmed by prisma.io

Did this fix it?

Cause 3 of 3

The project connects through Prisma Accelerate

You seeDATABASE_URL starts with prisma:// or prisma+postgres://

Check

An Accelerate URL is not a direct database connection, so it must not be given to PrismaPg. Version 7 expects it in its own constructor option.

Check
node -e "console.log((process.env.DATABASE_URL||'').split(':')[0])"

Fix

Pass the URL as accelerateUrl and keep the Accelerate extension, until you move to a direct connection with an adapter.

Fix
import { PrismaClient } from '../generated/prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

export const prisma = new PrismaClient({
  accelerateUrl: process.env.DATABASE_URL,
}).$extends(withAccelerate())

Verify

The client starts and a simple findFirst returns through Accelerate.

Verify
prisma.user.findFirst().then(console.log)

Confirmed by prisma.io

Did this fix it?

How do I stop it coming back?

  • Create the client in one module and import it everywhere, so a constructor change touches one file.
  • Upgrade prisma and @prisma/client together and to the same version.
  • Run the app's startup in CI after a major Prisma upgrade; this error never shows at compile time in plain JavaScript.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.