P
Prisma•6d ago
Darkstar

Could not locate Query Engine

Repo: https://github.com/DarkstarXDD/interactive-card-details-form Live site: https://interactive-card-details-form-darkstarxdd.vercel.app/ Prisma Client could not locate the Query Engine for runtime "rhel-openssl-3.0.x". Hi, I get this error when i deploy the project to Vercel. (Let me know if you need the full error message i can send it) I have searched online and came across multiple github discussions where others had encountered the same issue with different setups. I tried few solutions mentioned in those but nothing worked. I searched this server as well but there doesn't seem to be an exact solution. - This issue does not happen in development. I ran npm run build and tested this with a production version locally and still no errors. - When deployed to Vercel there are no build errors. - But at run time when i submit the data through my form and the Prisma query is called, it throws the error. My setup is extremely simple since it's a small practice project. - Next.js 15.2.4, App Router. - prisma CLI and @prisma/client 6.6.0. - Calling the Prisma query in a Server Action. - The database is Supabase Postgres. - Used the new custom path option to define a path in src/genereted/prisma/client. - Provider is the old prisma-client-js. - I have removed the generated folder from git tracking, and have added prisma generate in a postinstall script in the package.json. So the Prisma Client gets newly generated on the Vercel server during the production build. - I have followed this guide and created a globalForPrisma as well. Inside that i directly import the client from the generated output. When in earlier versions i didn't define a custom output i imported from @prisma/client. - I have tried adding binaryTargets as well, but didn't work.
9 Replies
Prisma AI Help
Prisma AI Help•6d ago
You've gone full bot mode! Let me fetch that AI answer for you ASAP.
Nurul
Nurul•5d ago
Hey 👋 What did you add in your binaryTargets? Was it something like this:
generator client {
provider = "prisma-client-js"
output = "./src/generated/prisma/client"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}
generator client {
provider = "prisma-client-js"
output = "./src/generated/prisma/client"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}
Nurul
Nurul•5d ago
Thanks for confirming. Can you do a quick check and see if the issue exists in prisma version 6.5.0 as well? We changed a lot of things in version 6.6.0, so I just want to be sure that this error is not related to the changes we did.
Darkstar
DarkstarOP•5d ago
Sure i can check. Should i remove the custom output path and let it create the prisma client inside the node_modules? Or should i just keep everything as it is an only change the version? I am not exactly sure whether the custom output path existed in 6.5.0. From my understanding it was added in version 6.6.0?
Nurul
Nurul•5d ago
Should i remove the custom output path and let it create the prisma client inside the node_modules?
Yes, you can keep the default behaviour of prisma client inside of node_modules
Darkstar
DarkstarOP•5d ago
I didn't switch to 6.5.0, but rather removed the custom output path while still using 6.6.0 and let it create the prisma client inside node_modules. And now it works all right. The above error is not present.
generator client {
provider = "prisma-client-js"
}
generator client {
provider = "prisma-client-js"
}
So seems like the custom path is causing the issue? I am not sure but since that's the only thing that i changed, it could be something related to that.
Nurul
Nurul•4d ago
Hmm! Super strange! It could be related to custom path. We started recommending usage of custom path in 6.6.0 release, so it can be related
Prisma AI Help
Prisma AI Help•3d ago
I can see you're encountering the "Query Engine not found" error when deploying your Prisma application to Vercel. This is a common issue when deploying Prisma applications to serverless environments like Vercel. Based on the knowledge sources, this error occurs because Prisma Client can't find the appropriate query engine binary for the runtime environment on Vercel. When you develop locally, Prisma uses your local machine's binary target, but when deployed to Vercel, it needs a different binary target (rhel-openssl-3.0.x). Solution Options 1. Add the correct binary target to your schema.prisma file:
generator client {
provider = "prisma-client-js"
output = "./src/generated/prisma/client"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}

generator client {
provider = "prisma-client-js"
output = "./src/generated/prisma/client"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}


This should include both your local environment's binary target ("native") and Vercel's environment binary target ("rhel-openssl-3.0.x"). 2. Use the Prisma NextJS monorepo workaround plugin: Several users in the knowledge sources mentioned success with this approach:
npm install @prisma/nextjs-monorepo-workaround-plugin

npm install @prisma/nextjs-monorepo-workaround-plugin


Then in your Next.js config file:
import { PrismaPlugin } from '@prisma/nextjs-monorepo-workaround-plugin'

/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config, { isServer }) => {
if (isServer) {
config.plugins = [...config.plugins, new PrismaPlugin()]
}
return config
},
}

export default nextConfig

import { PrismaPlugin } from '@prisma/nextjs-monorepo-workaround-plugin'

/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config, { isServer }) => {
if (isServer) {
config.plugins = [...config.plugins, new PrismaPlugin()]
}
return config
},
}

export default nextConfig


This was specifically mentioned as a solution in this GitHub issue. 3. For Next.js 15 specifically, you might need to use a static copy plugin to ensure the binary files are included in your deployment:
As mentioned in this GitHub issue, you can use a static copy plugin:
impo
rt { viteStaticCopy } from 'vite-plugin-static-copy'

export default defineConfig({
plugins: [
// other plugins
viteStaticCopy({
targets: [
{
src: "./src/generated/prisma/client/**/*.node",
dest: "./"
}
]
})
],
});

impo
rt { viteStaticCopy } from 'vite-plugin-static-copy'

export default defineConfig({
plugins: [
// other plugins
viteStaticCopy({
targets: [
{
src: "./src/generated/prisma/client/**/*.node",
dest: "./"
}
]
})
],
});

Additional Troubleshooting If the above solutions don't work, you might want to: 1. Check if your Vercel deployment is using Node 20, as there were specific issues reported with Node 20 deployments on Vercel in this GitHub issue. 2. Make sure your postinstall script is actually running during Vercel deployment. You can check the build logs to confirm. 3. Try explicitly setting the binary path in your PrismaClient initialization:
const prisma = new PrismaClient({
// You might need to adjust this path based on your deployment
__internal: {
engine: {
binaryPath: "/var/task/src/generated/prisma/client/libquery_engine-rhel-openssl-3.0.x.so.node"
}
}
});

const prisma = new PrismaClient({
// You might need to adjust this path based on your deployment
__internal: {
engine: {
binaryPath: "/var/task/src/generated/prisma/client/libquery_engine-rhel-openssl-3.0.x.so.node"
}
}
});

This issue is quite common with Prisma deployments on serverless platforms, and the Prisma team is aware of it. The upcoming Rust-based version of Prisma might help resolve these deployment issues in the future.

Did you find this page helpful?