3

Im using planestscale with prisma on a next js app that I'am trying to host on vercel but it runs on localhost without any error but as soon as I go to depolyment I count this error Authentication failed against database server at `aws.connect.psdb.cloud`, the provided database credentials for `name` are not valid.
I added the same env variable to vercel and Ihave the variable in an .env file

DATABASE_URL='mysql://<um>:<pw>Q@aws.connect.psdb.cloud/<db-name>?sslaccept=strict'

note: I replaced the placeholders

and this is my schema.prisma

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
  relationMode = "prisma"
}

why does'nt it work the same in deployment

ibo
  • 51
  • 3

2 Answers2

3

It could be that you are pushing the .env file to github.

Check the email that is related to your Planetscale account, you'll most likely have a mail saying the account details have been revoked.

You can remove the .env file with git rm .env --cached and on the gitignore file make sure you have:

.env
.env.local  
.env.staging

before pushing it back to github.

Jeusto
  • 3
  • 1
  • 1
Knee-co
  • 333
  • 2
  • 9
1

It Might be Helpful to just create a new password on PlanetScale. Just click on "Get Connection Strings" on the Overview Tab , then "new password" > "create password" , then make sure you copy that connection string into your .env file, Make sure .env is written on .gitignore and try again!

lucasluize
  • 76
  • 1
  • 5