Error validating datasource `db`: the URL must start with the protocol `prisma://` or `prisma+postgr
Attempting to run e2e tests in a docker environment against a standalone nextjs server container. I use prisma accelerate in production, but for tests these will run in a server environment - so accelerate is not desired. I am working on a dynamic build and runtime that allows for dynamically using accelerate depending on the environment, but for debugging this issue I've simplified things and I've removed prisma accelerate completely from this branch to try and isolate the cause of this issue.
This error is appearing in both 'test' and 'development' environments, also from Cypress runtime. But the db url is valid, the db is up, and I'm not using accelerate, i'm generating with --no-engine=false. So I don't understand why prisma is trying to use accelerate. Is there some way to have prisma print out why it's attempting to look for an accelerate url?
error log
schema.prisma
* continued in comments
5 Replies
You chose to compile with the bot. One moment while I piece together your answer…
prisma client
prisma generate
Test output (Cypress)
Based on the information in your question and the provided knowledge sources, the error:
typically occurs when Prisma expects a connection string for Accelerate or Data Proxy, but receives a standard PostgreSQL URL instead. This can happen if:
- You generated Prisma Client with the --no-engine flag, which tells Prisma to assume Accelerate/Data Proxy usage, even if your DATABASE_URL is a direct connection string. This is confirmed in multiple sources: using --no-engine in non-Accelerate environments causes Prisma to expect a prisma:// or prisma+postgres:// URL, leading to this error if you provide a postgresql:// URL instead. Removing --no-engine resolves the issue for direct database connections see discussion and issues here and here.
- The generated Prisma Client is not compatible with your intended environment. If you previously generated the client with --no-engine or for Accelerate, you must re-generate it without that flag for local/dev/test environments.
How to debug and resolve:
1. Ensure you are running npx prisma generate without --no-engine for your test/dev environment.
2. Delete your node_modules and the generated @prisma/client, then re-run npx prisma generate.
3. Double-check that your DATABASE_URL is set to a standard postgresql://... value in your environment.
There is no built-in Prisma command to print why it expects an Accelerate/Data Proxy URL, but the behavior is directly tied to how you generate the client and which flags you use source.
Summary:
Remove --no-engine from your generate command, re-generate the client, and ensure your DATABASE_URL is correct. This should resolve the error in your test and development environments. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Remove --no-engine from your generate command, re-generate the client, and ensure your DATABASE_URL is correct. This should resolve the error in your test and development environments. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Why is (engine=none) being set here?
Turns out my development
.env
file was getting pulled into the build, and included:
I had recently pulled the prod variables from vercel to put in my .env
, and within them all that flag env var was being set. I had no idea it was there. I didn't even think this .env
was being used because I have a test .env file that I'm passing to the run command. But since it is a field I didn't have assigned in the test .env it picked it up from the development one.
Would be great if there was a message about why engine was getting set to none, that would have saved me a full day of debugging 😅I am glad to hear that you were able to resolve this 🙌
There is this related GitHub Issue about a similar error:
https://github.com/prisma/prisma/issues/21902
GitHub
"Error validating datasource
db
: the URL must start with the prot...Bug description I have a monorepo with node.js micro services, each using their own database and prisma instance. I want to generate each prisma client without engines and let them use the engines ...