api git:(main) ✗ pnpm prisma migrate dev
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "localhost:2010"
Error: P1000: Authentication failed against database server at localhost
, the provided database credentials for postgres
are not valid.
Please make sure to provide valid database credentials for the database server at localhost
.enter image description here
Here’s the code of my docker-compose.yml file:
version: '3.8'
services:
db:
container_name: parkngo_db
image: postgres
restart: always
ports:
- 2010:5432
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: passcode
volumes:
- db_data_parkngo:/var/lib/postgresql/data
volumes:
db_data_parkngo:
The code of my .env file :
DATABASE_URL="postgresql://postgres:passcode@localhost:2010/postgres?schema=public"
and finally schema.prisma file:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
uid String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String?
Credentials Credentials?
AuthProvider AuthProvider?
Admin Admin?
}
// other models
Things I’ve already done:
- .env is in correct location
- docker is running in correct port (2010)
- postgres is running fine (port 2010 -> port 5432 (inside docker))
Apart from this prisma generate and studio command can be executed but obviously you can’t add records on it.
2
Answers
After trying almost everything, I thought to start over and surprisingly after removing all my containers and creating new ones resolved the problem.
Here are the commands for stopping running containers:
For removing all containers:
Are you sure you’re connecting to the correct postgres instance?
What if you try changing the connection-url to: