Free tool · Prisma ORM 6 · Next.js

Paste the Prisma error.
Get the fix.

20 Prisma errors AI agents keep causing, from P2002 to “did not initialize yet”, checked against Prisma 6.19. You get what it means, the fix and a prompt to hand back to Cursor or Claude Code.

prisma-error-fixer — runs in your browser, nothing is sent

try:

› 20 errors indexed. Matching runs locally as you type.

  • 20 errors
  • 9 P-codes
  • checked on Prisma ORM 6.19 · Next.js 16
  • updated

01The usual suspects

Your agent edits the schema. Nobody runs generate.

Prisma Client is generated code, and agents treat it like a normal library: they change schema.prisma, skip prisma generate, create a new PrismaClient() wherever they are and query from "use client" files. These 10 come up again and again:

  1. 01@prisma/client did not initialize yetThe agent ran npm install prisma @prisma/client but never prisma generateFix: run prisma generate (and add it to postinstall) →
  2. 02Property 'x' does not exist on type 'PrismaClient'The agent added a model to schema.prisma and went straight to writing queriesFix: run prisma generate after every schema change →
  3. 03Prisma has detected that this project was built on Vercelpackage.json has no postinstall or build step that runs prisma generateFix: prisma generate in the build script →
  4. 04PrismaClient is unable to run in this browser environmentA "use client" component imports db from lib/db.tsFix: query in a Server Component, pass plain data down →
  5. 05PrismaClient is not configured to run in Edge Runtimeexport const runtime = "edge" on a route or page that queries the databaseFix: remove runtime = "edge" →
  6. 06Environment variable not found: DATABASE_URLThe agent put DATABASE_URL in .env.local: Next.js reads it, but the Prisma 6 CLI only loads .envFix: DATABASE_URL in .env (not only .env.local) →
  7. 07P2021: The table does not exist in the current databaseThe agent added a model and ran prisma generate, but not db push or migrateFix: prisma migrate deploy / db push on that database →
  8. 08PrismaClientValidationError: Unknown argumentThe agent guessed a field name (userId vs ownerId, createdAt vs created_at)Fix: use field names from schema.prisma, not guesses →
  9. 09P2024: Timed out fetching a new connection from the connection poolnew PrismaClient() in many files, or inside a request handlerFix: one PrismaClient singleton + a pooled URL →
  10. 10Drift detected: database schema is not in sync with migration historyThe agent ran prisma db push on a database that also uses migrateFix: pick db push or migrate, not both →
  11. tell your agent
    • One PrismaClient, in lib/db.ts
    • Run prisma generate after schema changes
    • prisma db push or migrate dev, never neither
    • Query only from the server
    • No export const runtime = "edge"
    • Run next build before you finish
    Generate an AGENTS.md with these rules →

02Every error, explained

The full list.

01runtime erroragents cause this

@prisma/client did not initialize yet

Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.

@prisma/client is only a shell until prisma generate writes the real client for your schema. The code imported it before that ever happened on this machine or in this build.

usually because

  • The agent ran npm install prisma @prisma/client but never prisma generate
  • A fresh clone or CI build where nothing runs prisma generate
  • node_modules was cached from a build that had no schema yet

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Run npx prisma generate once locally
  2. 2.Add "postinstall": "prisma generate" to package.json so every install regenerates
  3. 3.Make the build script prisma generate && next build
package.json
"scripts": {
  "build": "prisma generate && next build",
  "postinstall": "prisma generate"
}
prompt for your agent

Prisma says @prisma/client did not initialize yet. Run prisma generate, then make it permanent: add "postinstall": "prisma generate" and change the build script to "prisma generate && next build" in package.json. Don't change the schema.

02type erroragents cause this

Property 'x' does not exist on type 'PrismaClient'

Type error: Property 'invoice' does not exist on type 'PrismaClient<PrismaClientOptions, never, DefaultArgs>'.

The model or field exists in schema.prisma but not in the generated client TypeScript sees. The client is generated code: it only changes when prisma generate runs.

usually because

  • The agent added a model to schema.prisma and went straight to writing queries
  • The model name is singular in the schema (model Invoice) but the code uses db.invoices
  • The editor's TypeScript server still has the old types cached

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Run npx prisma generate (prisma db push and prisma migrate dev also run it)
  2. 2.Use the lowercase model name: model Invoice becomes db.invoice
  3. 3.Restart the TypeScript server in your editor if the error stays after generating
prompt for your agent

TypeScript says a model doesn't exist on PrismaClient. Check prisma/schema.prisma for the model and its exact name, run prisma generate (or prisma db push for local dev), and fix any code that uses a plural or misspelled model name. Don't cast db to any.

03deploy erroragents cause this

Prisma has detected that this project was built on Vercel

Prisma has detected that this project was built on Vercel, which caches dependencies. This leads to an outdated Prisma Client because Prisma's auto-generation isn't triggered. To fix this, make sure to run the `prisma generate` command during the build process.

Vercel (and Netlify CI) reuse node_modules between builds, so the install step that would normally regenerate the client is skipped. Your deploy runs a client generated for an older schema, or none at all.

usually because

  • package.json has no postinstall or build step that runs prisma generate
  • The agent removed prisma generate from the build script while "cleaning up"

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Set the build script to prisma generate && next build
  2. 2.Or add "postinstall": "prisma generate"
  3. 3.Redeploy (no need to clear the cache once the script runs generate)
package.json
"scripts": {
  "build": "prisma generate && next build",
  "postinstall": "prisma generate"
}
prompt for your agent

The Vercel build fails because Prisma Client is outdated (Vercel caches dependencies). Update package.json so the build script is "prisma generate && next build" and add "postinstall": "prisma generate". Show me the diff.

04browser consoleagents cause this

PrismaClient is unable to run in this browser environment

Error: PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in `…`).
If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report

Prisma Client ended up in JavaScript that runs in the browser. It can only run on the server: it needs your database URL and a server-side engine.

usually because

  • A "use client" component imports db from lib/db.ts
  • A shared helper file imports Prisma and is also used by a Client Component
  • The agent fixed a hook error by adding "use client" to a page that queries the database

works with Prisma ORM 6.19 · Next.js 16last verified

prevent it · security.mdc (free Cursor Rules Pack): Database modules start with import "server-only", so they can't end up in a client bundle.

fix

  1. 1.Do the query in a Server Component, Server Action or route handler, and pass plain data to the Client Component as props
  2. 2.Add import "server-only" at the top of lib/db.ts, so any client import fails at build time with a clear message
  3. 3.Split helpers: keep database code in files only the server imports
src/lib/db.ts
import "server-only";
import { PrismaClient } from "@prisma/client";

const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient };
export const db = globalForPrisma.prisma ?? new PrismaClient();
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = db;
prompt for your agent

Prisma Client is being bundled into browser code. Find the "use client" file (or a helper it imports) that imports db or @prisma/client, move the query into a Server Component or Server Action, and pass plain serializable data down as props. Add import "server-only" to lib/db.ts.

05runtime erroragents cause this

PrismaClient is not configured to run in Edge Runtime

Error: PrismaClient is not configured to run in Edge Runtime (Vercel Edge Functions, Vercel Edge Middleware, Next.js (Pages Router) Edge API Routes, Next.js (App Router) Edge Route Handlers or Next.js Middleware). In order to run Prisma Client on edge runtime, either:
- Use Prisma Accelerate: https://pris.ly/d/accelerate
- Use Driver Adapters: https://pris.ly/d/driver-adapters

The default Prisma 6 client needs Node.js. Code that imports it is running on the Edge runtime or Cloudflare Workers, where it can't open a normal database connection.

usually because

  • export const runtime = "edge" on a route or page that queries the database
  • An old middleware.ts (Edge) that calls auth() with a Prisma adapter
  • Deploying a Node.js Next.js app to Cloudflare Workers without a driver adapter

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Delete export const runtime = "edge": the Node.js runtime is the default and runs Prisma fine
  2. 2.On Next.js 16, rename middleware.ts to proxy.ts: proxy runs on Node.js
  3. 3.If you really need the edge or Workers, use a driver adapter (Neon, PlanetScale, D1) or Prisma Accelerate
prompt for your agent

Prisma Client fails on the Edge runtime. Find every export const runtime = "edge" in files that import db (directly or through auth), remove it so the route uses the default Node.js runtime, and on Next.js 16 make sure middleware.ts is migrated to proxy.ts. Don't add Prisma Accelerate unless I ask.

06runtime erroragents cause this

Environment variable not found: DATABASE_URL

error: Environment variable not found: DATABASE_URL.
  -->  schema.prisma:8
   |
 7 |   provider = "postgresql"
 8 |   url      = env("DATABASE_URL")

schema.prisma reads the connection string from env("DATABASE_URL") and it isn't set where this command or server is running.

usually because

  • The agent put DATABASE_URL in .env.local: Next.js reads it, but the Prisma 6 CLI only loads .env
  • It's set locally but not in the Vercel (or other host) project settings
  • It's set for Production but not Preview deployments

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.For local dev, put DATABASE_URL in .env (keep it in .gitignore)
  2. 2.Add it in your host's environment variables for every environment that builds or runs the app, then redeploy
  3. 3.Check the spelling: the name in env("…") must match exactly
prompt for your agent

Prisma can't find DATABASE_URL. Check which env files exist: the Prisma 6 CLI only reads .env, not .env.local. Put DATABASE_URL in .env for local dev, make sure .env is gitignored, and list the hosting environment variables I still need to set. Don't print the secret value.

07runtime error

The URL must start with the protocol postgresql://

error: Error validating datasource `db`: the URL must start with the protocol `postgresql://` or `postgres://`.
  -->  schema.prisma:8

DATABASE_URL is set, but it doesn't match the provider in schema.prisma. Prisma checks the protocol before connecting.

usually because

  • provider = "postgresql" but DATABASE_URL is still file:./dev.db (or the other way round)
  • The Supabase or Neon project URL (https://…) pasted instead of the database connection string
  • Quotes or a space copied into the value in the hosting dashboard

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Make the provider and the URL agree: postgresql:// for Postgres, file: for SQLite
  2. 2.Copy the connection string from the database's Connect panel, not the API URL
  3. 3.Paste the raw value in the dashboard, without quotes
prompt for your agent

Prisma says the datasource URL has the wrong protocol. Compare the provider in prisma/schema.prisma with the protocol of DATABASE_URL (don't print the full value, just the scheme) and tell me which one to change. If I'm moving from SQLite to Postgres, update the provider and remind me to run prisma db push or migrate.

08P1001runtime error

P1001: Can't reach database server

PrismaClientInitializationError: Can't reach database server at `db.example.supabase.co:5432`

Please make sure your database server is running at `db.example.supabase.co:5432`.

Prisma couldn't open a network connection to the host and port in DATABASE_URL. Nothing about your schema or query yet: it's the network, the host or the database itself.

usually because

  • The local database (Docker, Postgres.app) isn't running
  • A paused free-tier database (Supabase and Neon pause or suspend idle projects)
  • The direct host is IPv6-only and your network or host has no IPv6: use the provider's pooler host
  • Wrong host or port, or a firewall / IP allow list blocking the server

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Start or unpause the database, then retry
  2. 2.Copy a fresh connection string from the provider dashboard (for Supabase from a serverless host, use the pooler connection string)
  3. 3.Check the host's IP allow list if your provider has one
prompt for your agent

Prisma throws P1001 Can't reach database server. Without printing secrets, check the host and port in DATABASE_URL, tell me whether it's a direct or pooled connection, and list the likely causes for my provider (paused project, IPv6-only direct host, firewall). Don't change the schema.

09P1000runtime error

P1000: Authentication failed against database server

Authentication failed against database server, the provided database credentials for `postgres` are not valid.

Please make sure to provide valid database credentials for the database server at the configured address.

The server was reached but rejected the username or password in DATABASE_URL.

usually because

  • A password with @, #, / or : that isn't URL-encoded, so the URL is parsed wrong
  • The database password was reset and the env var still has the old one
  • Pooler connection strings that need the user as postgres.<project-ref>, not just postgres

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.URL-encode special characters in the password (@ becomes %40, # becomes %23)
  2. 2.Copy the full connection string again from the provider and update it everywhere
  3. 3.Redeploy after changing environment variables
prompt for your agent

Prisma throws P1000 authentication failed. Without printing the password, check whether DATABASE_URL's password contains characters that need URL-encoding and whether the username format matches my provider's pooler. Tell me exactly what to change.

10P2021query erroragents cause this

P2021: The table does not exist in the current database

PrismaClientKnownRequestError:
Invalid `db.invoice.findMany()` invocation:

The table `public.Invoice` does not exist in the current database.

The client knows about the model, but the database it's connected to was never given that table. The schema changed and nobody pushed or migrated this database.

usually because

  • The agent added a model and ran prisma generate, but not db push or migrate
  • Production points at a different database than the one you migrated locally
  • Migrations exist but the deploy never runs prisma migrate deploy

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Local prototype: npx prisma db push
  2. 2.With migrations: npx prisma migrate dev locally, then npx prisma migrate deploy against production
  3. 3.Check DATABASE_URL points at the database you think it does
prompt for your agent

Prisma throws P2021: the table doesn't exist. Check whether this project uses migrations (prisma/migrations) or db push, then give me the exact command to sync the schema to the database DATABASE_URL points at, and add migrate deploy to the deploy step if migrations are used.

11P2002query error

P2002: Unique constraint failed

PrismaClientKnownRequestError:
Invalid `db.user.create()` invocation:

Unique constraint failed on the fields: (`email`)

You tried to create or update a row with a value that must be unique (an email, a Stripe customer id, a slug) and another row already has it.

usually because

  • Sign-up or seed code that always calls create, even when the record exists
  • A Stripe webhook delivered twice, each delivery creating the same row
  • Two requests racing to create the same record

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Use upsert when "create or update" is what you mean
  2. 2.Catch the error by code: error instanceof Prisma.PrismaClientKnownRequestError && error.code === "P2002", and show a friendly message
  3. 3.For webhooks, store the event id with a unique constraint and skip duplicates
src/lib/customers.ts
await db.user.upsert({
  where: { email },
  update: { stripeCustomerId },
  create: { email, stripeCustomerId },
});
prompt for your agent

Prisma throws P2002 Unique constraint failed. Find the create or update that hits it, decide whether it should be an upsert, and otherwise catch Prisma.PrismaClientKnownRequestError with code P2002 and return a clear error to the user. Don't remove the @unique from the schema.

12P2025query error

P2025: Record required but not found

PrismaClientKnownRequestError:
Invalid `db.user.update()` invocation:

An operation failed because it depends on one or more records that were required but not found. No record was found for an update.

update, delete, connect or a findUniqueOrThrow / findFirstOrThrow call needed a row that wasn't there.

usually because

  • Updating by an id or email that doesn't exist (or belongs to another user's filter)
  • Deleting something that was already deleted, often a double-clicked button or a retried webhook
  • connect: { id } pointing at a missing related record

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.If missing is normal, use updateMany / deleteMany (they return a count instead of throwing) or findUnique and check for null
  2. 2.Otherwise catch code P2025 and return a 404
  3. 3.Check the where clause uses a field that's really unique for this user
prompt for your agent

Prisma throws P2025 record not found. Find the update, delete, connect or *OrThrow call, and decide whether a missing record is expected. If it is, switch to findUnique + null check or updateMany/deleteMany; if not, catch P2025 and return a 404. Show me the diff.

13P2003query error

P2003: Foreign key constraint violated

PrismaClientKnownRequestError:
Invalid `db.post.create()` invocation:

Foreign key constraint violated on the foreign key

A row points at a related row that doesn't exist (on create or update), or you deleted a row that other rows still point at.

usually because

  • Creating a record with a userId from a stale session or a hard-coded id
  • Deleting a user that still has posts, subscriptions or accounts
  • Seed scripts that insert children before parents

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Use connect with an id you just read from the database (or the signed-in session)
  2. 2.Add onDelete: Cascade to the relation if children should go with the parent, then push or migrate
  3. 3.Insert parents before children in seeds, or wrap both in db.$transaction
prompt for your agent

Prisma throws P2003 foreign key constraint violated. Find which relation it is, check whether the parent record exists, and either fix the id being used or add onDelete: Cascade (or SetNull) to the relation if that's the intended behavior. Tell me before changing the schema.

14query erroragents cause this

PrismaClientValidationError: Unknown argument

PrismaClientValidationError:
Invalid `db.user.findMany()` invocation:

{
  where: {
    emial: "[email protected]",
    ~~~~~
  }
}

Unknown argument `emial`. Did you mean `email`? Available options are marked with ?.

The query uses a field or option the generated client doesn't know. Prisma checks every query against your schema before sending it.

usually because

  • The agent guessed a field name (userId vs ownerId, createdAt vs created_at)
  • The field exists in schema.prisma but the client wasn't regenerated
  • A relation filter written like a scalar: where: { user: id } instead of where: { userId: id }

works with Prisma ORM 6.19 · Next.js 16last verified

prevent it · 00-workflow.mdc (free Cursor Rules Pack): The agent searches the schema instead of inventing field names, and trusts the installed types over memory.

fix

  1. 1.Use the name Prisma suggests after "Did you mean"
  2. 2.If the field is new, run npx prisma generate
  3. 3.Let TypeScript check queries: don't type db or the query args as any
prompt for your agent

Prisma throws a PrismaClientValidationError (Unknown argument). Read prisma/schema.prisma, then fix the query to use the real field names. If the field was just added, run prisma generate. Don't cast to any to silence it.

15query error

PrismaClientValidationError: Argument is missing

PrismaClientValidationError:
Invalid `db.post.create()` invocation:

{
  data: {
    title: "Hello",
+   user: {
+     create: UserCreateWithoutPostsInput | UserUncheckedCreateWithoutPostsInput,
+     connectOrCreate: UserCreateOrConnectWithoutPostsInput,
+     connect: UserWhereUniqueInput
+   }
  }
}

Argument `user` is missing.

A required field or relation wasn't provided. The lines marked with + show what Prisma expected.

usually because

  • Creating a child record without its owner (no userId and no user: { connect })
  • A new required field added to the schema, while existing create calls weren't updated

works with Prisma ORM 6.19 · Next.js 16last verified

prevent it · 00-workflow.mdc (free Cursor Rules Pack): The agent reads the schema and installed types before writing a query, instead of guessing required fields.

fix

  1. 1.Pass the relation: user: { connect: { id: session.user.id } } (or userId directly)
  2. 2.When adding a required field to an existing model, give it a @default or make it optional first
prompt for your agent

Prisma says an argument is missing on create. Read the marked lines in the error, then pass the missing field or relation (for user-owned records, connect the signed-in user's id from the session). If a new required field caused it, suggest a @default.

16P2024runtime erroragents cause this

P2024: Timed out fetching a new connection from the connection pool

PrismaClientKnownRequestError: Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 5)

Every connection Prisma may open is busy, or the database refused more. In Next.js this is almost always too many PrismaClient instances, or serverless functions each holding their own pool.

usually because

  • new PrismaClient() in many files, or inside a request handler
  • next dev hot reload creating a fresh client on every change (no globalThis singleton)
  • Serverless functions connecting straight to Postgres instead of through a pooler

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Create PrismaClient once in lib/db.ts with the globalThis pattern and import db everywhere
  2. 2.On serverless, use the provider's pooled connection string (Supabase port 6543 with ?pgbouncer=true, or Neon's -pooler host)
  3. 3.Use a direct (non-pooled) URL as directUrl in schema.prisma, for migrations
prisma/schema.prisma
datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL") // pooled
  directUrl = env("DIRECT_URL")   // direct, used by migrate
}
prompt for your agent

Prisma throws P2024 (connection pool timeout). Search the codebase for every new PrismaClient(), replace them with one globalThis singleton in lib/db.ts, and tell me whether DATABASE_URL is a pooled connection. If it isn't, show me the schema.prisma change for url + directUrl.

17prisma migrateagents cause this

Drift detected: database schema is not in sync with migration history

Drift detected: Your database schema is not in sync with your migration history.

We need to reset the "public" schema at "localhost:5432"

You may use prisma migrate reset to drop the development database.
All data will be lost.

prisma migrate dev compared the database to the migrations folder and they disagree: something changed the database outside a migration.

usually because

  • The agent ran prisma db push on a database that also uses migrate
  • Someone edited a table by hand in the provider's dashboard
  • A migration file was edited or deleted after it was applied

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.On a dev database with throwaway data, let migrate reset it
  2. 2.Never answer yes on a database with real data: back it up, then create a migration for the difference (prisma migrate diff) or baseline
  3. 3.Pick one workflow per database: db push for prototypes, migrate for anything in production
prompt for your agent

prisma migrate dev reports drift and wants to reset the database. Don't confirm the reset. Tell me what changed (compare with prisma migrate diff), whether this database has real data, and the safe way to get back in sync. Use migrations only from now on.

18P3005prisma migrate

P3005: The database schema is not empty

Error: P3005

The database schema is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline

prisma migrate deploy found tables but no migration history, usually because the database was created with db push. It won't guess which migrations are already applied.

usually because

  • The project started with prisma db push and later switched to migrations
  • Tables created by hand or by another tool

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Create a baseline migration from the current schema
  2. 2.Mark it as applied with npx prisma migrate resolve --applied <migration_name>
  3. 3.Run npx prisma migrate deploy for later migrations
prompt for your agent

prisma migrate deploy fails with P3005 (schema not empty). Walk me through baselining: generate an initial migration that matches the current database, mark it applied with prisma migrate resolve --applied, and confirm with migrate status. Don't drop or reset anything.

19P3009prisma migrate

P3009: migrate found failed migrations

Error: P3009

migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
The `20261025_add_invoices` migration started at 2026-10-25 14:02:11 UTC failed with the following logs: …

A previous migrate deploy failed halfway, and Prisma blocks every later migration until you say what happened to that one.

usually because

  • A migration that adds a required column to a table that already has rows
  • A unique index on a column with duplicate values
  • A timeout or lost connection during deploy

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Read the failed migration's error and fix the data or the SQL
  2. 2.If the changes were rolled back: npx prisma migrate resolve --rolled-back <name>, then deploy again
  3. 3.If you applied them by hand: npx prisma migrate resolve --applied <name>
prompt for your agent

prisma migrate deploy fails with P3009. Find the failed migration in the error, explain why it failed, and tell me whether to resolve it as --rolled-back or --applied. Fix the migration (for example a default for a new required column) before redeploying.

20deploy error

Prisma Client could not locate the Query Engine

PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "rhel-openssl-3.0.x".

This happened because Prisma Client was generated for "darwin-arm64", but the actual deployment required "rhel-openssl-3.0.x".

The client was generated on one OS (your Mac, Windows or a different Linux) and deployed to another, so the native engine file for the server isn't there.

usually because

  • The generated client or node_modules was committed or copied from your laptop
  • A Docker image on Alpine (linux-musl) while the client was generated on Debian
  • A monorepo or custom output path the bundler doesn't copy

works with Prisma ORM 6.19 · Next.js 16last verified

fix

  1. 1.Run prisma generate during the build on the target machine, not locally
  2. 2.Don't commit node_modules or the generated client
  3. 3.If you must generate elsewhere, add the target to binaryTargets in the generator block
prisma/schema.prisma
generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "rhel-openssl-3.0.x"]
}
prompt for your agent

Prisma can't find the query engine for the deployment runtime. Check whether the generated client or node_modules is committed, make sure prisma generate runs in the build on the server, and only if needed add the runtime from the error to binaryTargets.

03Or start from code that already builds

Prisma, already wired the way agents can't break.

Skip the setup. The VibeBoot SaaS Starter ships a ready prisma/schema.prisma and one Prisma client in src/lib/db.ts (SQLite by default, Postgres by changing the provider), plus auth and Stripe on Next.js 16.4.3. $49, one-time.

14-day money-back guarantee · lifetime updates

See everything that's inside →
  • One client · lib/db.ts is the only PrismaClient (globalThis singleton), and AGENTS.md says never to instantiate it elsewhere
  • Generate on every build · prisma generate runs in both build and postinstall, so Vercel's dependency cache can't ship a stale client
  • SQLite → Postgres · npm run db:push creates a local SQLite database; the README covers switching the provider to Postgres for production
  • Server-only queries · the rules say to query db only inside Server Components or Server Actions
  • No Prisma on the Edge · the Next.js 16 proxy.ts only rate-limits and never imports the database, and no route sets runtime = "edge"

FAQ

Why do AI coding agents cause so many Prisma errors?

Prisma Client is generated code. Agents edit schema.prisma and go straight to writing queries without running prisma generate, push or migrate, so the client, the types and the database drift apart. They also create new PrismaClient() in whatever file they're in, import the database into "use client" components, and add runtime = "edge" to routes. Rules in AGENTS.md or .cursor/rules that say "one client in lib/db.ts, run prisma generate after schema changes, query only on the server" prevent most of them.

What do Prisma error codes like P2002 or P1001 mean?

P1xxx codes are connection and setup problems (P1000 bad credentials, P1001 can't reach the server). P2xxx codes come from a query (P2002 unique constraint, P2003 foreign key, P2021 missing table, P2024 pool timeout, P2025 record not found). P3xxx codes come from prisma migrate (P3005 schema not empty, P3009 failed migrations). Paste just the code above to jump to it.

Should I use prisma db push or prisma migrate?

db push is great for prototypes and local SQLite: it syncs the schema without migration files. Once a database has real data, use prisma migrate dev locally and prisma migrate deploy in production, and stop using db push on that database, or you'll get drift.

Is anything I paste sent to a server?

No. The matcher is plain JavaScript in this page. Nothing you paste is stored or sent anywhere, so it's fine to paste errors that contain hostnames. Still, don't paste full connection strings with passwords anywhere.

Which Prisma version is this for?

Prisma ORM 6 (checked against 6.19.3 on October 25, 2026) with the prisma-client-js generator, used from a Next.js 16 app. The query, connection and validation errors were reproduced in a test project; the rest are the error strings shipped in the Prisma 6.19.3 packages. Most entries also apply to Prisma 5.

Sources: errors reproduced against prisma and @prisma/client 6.19.3 in a test project (SQLite and Postgres clients), the error strings shipped in those packages, and the Prisma docs on error codes, the connection pool and baselining. Checked October 25, 2026. Spotted a mistake? Email [email protected].

Also free: Next.js error fixer · Env leak checker · Auth.js error fixer · newsletter

$ fixed it? get the next one first

New fixes for what AI agents break, by email.

When we add a fix or a Cursor rule for a new Next.js, Auth.js, Prisma or Stripe break, it goes out in the VibeBoot newsletter. Free, occasional, unsubscribe in one click.

Subscribe free

> More free tools

All tools →