Error validating datasource db
: the URL must start with the protocol postgresql://
or postgres://
#12170
Replies: 37 comments 55 replies
-
I also faced the same issue. I rechecked the connection string generated from free Postgres instance of Heroku, did not help. I rechecked on changing it to local DB nothing helped. I do have repo of this. But I really don't know how to reproduce this issue. |
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 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.
-
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.
-
※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.
-
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 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 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.
-
i'd solved it! in my case, i remove the semicolmn on at .env file. probably my linter does that. but it's true. when i put any semicoln in the .env, it will show the unrelevant error. |
Beta Was this translation helpful? Give feedback.
-
Just delete |
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.
-
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.
-
just moving .env file to ./prisma/.env worked for me. -Docker version 20.10.24, build 297e128 |
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.
-
In my environment I resolved this issue
|
Beta Was this translation helpful? Give feedback.
-
My issue is that my package.json I had |
Beta Was this translation helpful? Give feedback.
-
I solved it by changing |
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 got this error while deploying to vercel. i need help |
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.
-
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.
-
Issues occurred when there is an env.example, removing that file fixed my issues. No need to remove quotes. Also be sure the connection string has no errors after copying from db provider, i.e planetscale. |
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 tried everything listed here. What solved it for me was the follwing: // schema.prisma
datasource db {
provider = "postgresql"
url = env("NEWNAME_DATABASE_URL")
} // .env
NEWNAME_DATABASE_URL=postgres://postgres.... After this I ran I conclude, that another environment variable named |
Beta Was this translation helpful? Give feedback.
-
I had the same problem. The solution was that there was already a DATABASE_URL variable defined in my OS. I had defined it for a java application. That's why prism gave an error, because the string started with "jdbc:" and not "postgresql://". Try checking in your terminal if the variable exists Linux Windows |
Beta Was this translation helpful? Give feedback.
-
Removing |
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