Error validating datasource db
: the URL must start with the protocol postgresql://
or postgres://
#12170
Replies: 37 comments 55 replies
-
Ran into this similar error but only in the context of a production box and not local. My issue was that my environment variable was in the format of |
Beta Was this translation helpful? Give feedback.
-
If you recently swapped your DATABASE_URL, make sure you run |
Beta Was this translation helpful? Give feedback.
-
my problem was that import { PrismaClient } from '@prisma/client/edge' so i just used @prisma/client and it worked! |
Beta Was this translation helpful? Give feedback.
-
I also face the same issue 😞 |
Beta Was this translation helpful? Give feedback.
-
I had this problem while working with the next-auth demo repo. The problem ended up being a second declaration of |
Beta Was this translation helpful? Give feedback.
-
Take attention when you're configuring your PrismaService. I was importing like this and I've changed for This simple change worked for me. Hope help you! |
Beta Was this translation helpful? Give feedback.
-
I was having the same issue, having prisma inside a Docker Container. |
Beta Was this translation helpful? Give feedback.
-
I had this exact issue today, in a nextjs project using next-auth and postgres as my db after double checking it wasn't something silly like a spelling error, removed my .next folder and all contents, ran Hope this helps 👍🏻 |
Beta Was this translation helpful? Give feedback.
-
I got this issue
[dxlord.🐼.007] final_portfolio (db_int)$ npx prisma db push
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database
Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: Environment variable not found: DATABASE_URL.
--> schema.prisma:10
|
9 | provider = "postgresql"
10 | url = env("DATABASE_URL")
|
Validation Error Count: 1
[Context: getConfig]
Prisma CLI Version : 4.13.0 Then I just simply renamed the file
|
Beta Was this translation helpful? Give feedback.
-
I faced this issue when added prisma to existing project, using |
Beta Was this translation helpful? Give feedback.
-
like others in the comment, I had tried prisma edge related products thus had
in my scripts for build. Remove |
Beta Was this translation helpful? Give feedback.
-
I solved it by changing |
Beta Was this translation helpful? Give feedback.
-
My issue is that my package.json I had |
Beta Was this translation helpful? Give feedback.
-
I'm facing the same error and I did all the suggestions in this thread, with no success. I fixed! The .env is loaded from OS environment variables first, and if is not there then is loaded from .env file. Don't forget to close and open the text editor (vscode) every time you change something in the Windows environment variable. After wasting a lot of time I did it. Thank god! Thanks all |
Beta Was this translation helpful? Give feedback.
-
My issue was I already has a key in the OS Environment Variable, so
instead get from my .env it was getting from OS Variable, I deleted the OS
Variable and works fine.
The priority is OS then .env
Em ter., 16 de jan. de 2024 às 04:39, Abdullah Ijaz <
***@***.***> escreveu:
… I encountered an error saying that
error: Error validating datasource db: the URL must start with the
protocol postgresql:// or postgres://.
--> schema.prisma:18
But after updating anything on schema.prisma or in env file
You must have to restart the application and prisma studio
Then error will be resolved
—
Reply to this email directly, view it on GitHub
<#12170 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZQYNFJF6Q34HD7VLE6PMTYOYVB7AVCNFSM5QAFQG6KU5DIOJSWCZC7NNSXTOKENFZWG5LTONUW63SDN5WW2ZLOOQ5TQMJUGA3TCMI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Same in Blockscout backend .env file. Solved by removing double quotes. Use single quotes or no quotes at all. |
Beta Was this translation helpful? Give feedback.
-
a very herculean effort to find that there was a whitespace at the end of the line ;) |
Beta Was this translation helpful? Give feedback.
-
Just remote quotes in your connection, it will work |
Beta Was this translation helpful? Give feedback.
-
I encountered an error saying that error: Error validating datasource But after updating anything on schema.prisma or in env file You must have to restart the application and prisma studio Then error will be resolved |
Beta Was this translation helpful? Give feedback.
-
Removing |
Beta Was this translation helpful? Give feedback.
-
I got this error while deploying to vercel. i need help |
Beta Was this translation helpful? Give feedback.
-
In my environment I resolved this issue
|
Beta Was this translation helpful? Give feedback.
-
Firstly thank you everyone, Hope this helps if someone is also facing the same issue because it wasted a lot of time for me. |
Beta Was this translation helpful? Give feedback.
-
nothing else here worked but the thing that did work for me was to use I'm working with prisma + trpc. I hope this helps someone 👌 thanks everyone. |
Beta Was this translation helpful? Give feedback.
-
it can perfectly work. I work step-by-step as |
Beta Was this translation helpful? Give feedback.
-
just fyi for sequelite it should be this: DATABASE_URL=file:./db.sqlite |
Beta Was this translation helpful? Give feedback.
-
Just delete |
Beta Was this translation helpful? Give feedback.
-
I had the same problem today. what i found is that prisma tried to read the env variable from the os exported env variables, because i added the .env to my docker-compose.yml. the solution i found is unseting the env DATABSE_URL after an exec into the container. |
Beta Was this translation helpful? Give feedback.
-
Importing the 'dotenv-safe/config inside the jest.config file is what worked for me. `require('dotenv-safe/config') process.env.DB_URL = exec('yarn db:migrate') |
Beta Was this translation helpful? Give feedback.
-
※I'm sorry if it's a strange English because I'm translating it into English with google translate. I had the same error, but I resolved it, so I'll post it here. ①There are two prisma.schema files, and the prisma described was wrong Also, prisma/prisma.shema」 did not have 「.env」, so it was created and migrated successfully |
Beta Was this translation helpful? Give feedback.
-
I am trying to run simple migration using
prisma migrate dev
. I have my.env
file set up in the root directory of my application.I have defined the
DATABASE_URL
in my.env
file. But when I try to run migrations, I am getting the following logs.I have tried:
@prisma/cli@3.8.1
prisma@3.8.1
.env
file to./prisma/.env
Beta Was this translation helpful? Give feedback.
All reactions