Reputation: 11
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:
Apart from this prisma generate and studio command can be executed but obviously you can't add records on it.
Upvotes: 0
Views: 820
Reputation: 11
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:
docker stop $(docker ps -aq)
For removing all containers:
docker rm $(docker ps -aq)
docker rmi $(docker images -q) # Optionally, remove all images
docker network prune # Remove all unused networks
Upvotes: 1
Reputation: 868
Are you sure you're connecting to the correct postgres instance?
What if you try changing the connection-url to:
DATABASE_URL="postgresql://postgres:passcode@parkngo_db:2010/postgres?schema=public"
Upvotes: 0