the URL must start with the protocol `mongo`
I have been geting this error recently, and I have no idea why. my mongodb DATABASE_URL is without " ", I have tried deleting and installing node_modules again and again. Building the app works, dev mode works too. But "prisma db push" and other commands show the attached error.
7 Replies
in your .env file, does your DATABASE_URL start with "mongodb://" or "mongodb+srv:/"?
mongodb+srv:/
When I put the URI directly in the schema instead of env("DATABASE_URL"), then it works, otherwise it doesn't
Okay, if I use DATABASE_URI instead of DATABASE_URL, then it works too, the problem seems to only be when using DATABASE_URL
yes, variable name must match the ones inside .env file.
env variable was not imported correctly.
What I meant was, if I change both the .env file variable and the prisma chema variable name to DATABASE_URI, it works
But if I change both to DATABASE_URL, it doesn't
hmm, never encountered that issue before...
is your DATABASE_URL named as "DATABASE_URL" on vercel side as well? it sounds like a typo or importing issue though.
What do you mean by Vercel side?
if you are deploying next.js app on vercel, you need env variables on vercel. it's under the settings tab and Environment Variables on the left.