P
Prisma•4d ago
UsernameHere

Can't use a locally hosted postgresql database on Prisma.

It keeps throwing the error 'Error validating datasource db: the URL must start with the protocol prisma://', though I see many people using it all the time. My schema is
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
, and then normal models. I genuinely cannot figure out for the life of me on why I can't do this.
4 Replies
Prisma AI Help
Prisma AI Help•4d ago
You opted for speed from this bot. Let's conjure up an answer right now! Based on the information provided in the knowledge sources, it appears that the error you're encountering is not related to using a locally hosted PostgreSQL database with Prisma. In fact, the error message you're seeing is inconsistent with the typical error for an invalid PostgreSQL connection string. Let me explain: 1. The error message you're getting ("Error validating datasource db: the URL must start with the protocol prisma://") is actually associated with using Prisma Accelerate, not a standard PostgreSQL connection. This is mentioned in the Github Issue #23448. 2. For a standard PostgreSQL connection, the URL should indeed start with postgresql:// or postgres://. The error message for an invalid PostgreSQL URL would typically mention this, as seen in this Github Issue. To resolve your issue: 1. Check your .env file. Make sure you have a DATABASE_URL environment variable set with the correct PostgreSQL connection string. It should look something like this:
DATABASE_URL="postgresql://username:password@localhost:5432/your_database_name?schema=public"

DATABASE_URL="postgresql://username:password@localhost:5432/your_database_name?schema=public"

This is mentioned in the Prisma documentation for connecting to your database. 2. Ensure that you're not accidentally using a Prisma Accelerate URL (which starts with prisma://) in your .env file. 3. Double-check that your schema.prisma file is correctly set up, which it appears to be based on what you've shared. 4. If you've recently changed your connection string, try running prisma generate to ensure your client is up to date with the latest changes. If you've confirmed all of the above and are still encountering issues, it might be worth checking if there are any conflicting environment variables or if your Pr isma version is up to date. Remember, for a local PostgreSQL database, your connection string should always start with postgresql:// or postgres://, not prisma://. 🤔 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.
UsernameHere
UsernameHereOP•4d ago
wait one second i mightve fixed it ok yeah I fixed it
Nurul
Nurul•4d ago
Glad to hear that! Were you using directUrl parameter as well, which caused this?
UsernameHere
UsernameHereOP•4d ago
no, somehow it just didn't like the fact I had pulse and accelerate installed, though they weren't even included in my script and just kept erroring until I uninstalled them

Did you find this page helpful?