Skip to content

Instantly share code, notes, and snippets.

@aayushchugh
Created June 5, 2023 13:13
Show Gist options
  • Select an option

  • Save aayushchugh/5b67d62031dee8e00c842a9ff10b0b6d to your computer and use it in GitHub Desktop.

Select an option

Save aayushchugh/5b67d62031dee8e00c842a9ff10b0b6d to your computer and use it in GitHub Desktop.
Authentication failed against database server at localhost, the provided database credentials for johndoe are not valid. in prisma

So I was facing this error while connecting postgreSQL with prisma

Authentication failed against database server at localhost, the provided database credentials for johndoe are not valid.

I spent 2 days solving this and these were the errors in my code

1. Problem: Multiple .env files

There were 2 .env files, 1st in the folder of my server and 2nd in the parent folder (this was a monorepo) with same variable in both files i.e. DATABASE_URL

Solution: I deleted the .env present in parent folder

2. Problem: Prisma was not able to read my .env file

Solution: I used dotenv package from npm

  1. install dotenv using yarn
yarn add dotenv
  1. Add this code in app.module.ts or main.ts file
import { config } from "dotenv";

config();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment