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
hutajoullach
hutajoullach2y ago
in your .env file, does your DATABASE_URL start with "mongodb://" or "mongodb+srv:/"?
kshitijmohan15
kshitijmohan15OP2y ago
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
hutajoullach
hutajoullach2y ago
yes, variable name must match the ones inside .env file. env variable was not imported correctly.
kshitijmohan15
kshitijmohan15OP2y ago
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
hutajoullach
hutajoullach2y ago
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.
kshitijmohan15
kshitijmohan15OP2y ago
What do you mean by Vercel side?
hutajoullach
hutajoullach2y ago
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.
Want results from more Discord servers?
Add your server