prisma: migrate deploy: Error: P1010: User `user` was denied access on the database `db.public`
Bug description
migrate deploy throws Error: P1010: User user was denied access on the database db.public
How to reproduce
run migrate deploy
Expected behavior
migrations should run and tables on the migration should be created
since this is a production deploy, no shadow database should be necessary as per the documentation:
The migrate deploy command:
- Does not issue a warning if an already applied migration is missing from migration history
- Does not detect drift (production database schema differs from migration history end state - for example, due to a hotfix
- Does not reset the database or generate artifacts (such as Prisma Client)
- Does not rely on a shadow database
the user used has grant all on the database schema and its a superuser
Prisma information
datasource db { provider = "postgresql" url = env("DATABASE_URL") }
postgresql://postgres:[pwd]@localhost:5432/postgres?schema=public
Environment & setup
- OS: CentOS Stream 9
- Database: PostgreSQL 13.7
- Node.js version: v16.14.0
Prisma Version
3.10.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 31 (7 by maintainers)
For anyone running into this in the future, you have to map the port to another one, as the error (in my case) came from ports colliding.
Final
docker-compose.yml:Then connect to it using
postgresql://postgres:postgres@localhost:5555/my-db?schema=publicShould work then!
For me it was my other local running instance of postgres. Previously I had installed postgres.app and pgadmin for another project and had it running in the background. So if you’re running postgres inside docker, be sure to quit any other local postgres instances. Soon as I did that the issue went away.
no it does not, the error I get is the one posted above…
it does, and thanks to you I found the issue, since it’s a peer connection, the way the connection works requires an OS user to initiate the connection directly.
updating pg_hba.conf to reflect a localhost connection trusted for the user solved the issue
it was indeed a problem with Postgres and not prisma.
thank you and absolutely in love with the project
keep it up!
Can you elaborate on how exactly have you modified the config file?
For any other like me that stumbled upon this while trying to use a Remix
Stackproject with adocker-composeusing Postgres included, I simply specified a differentvolumefor the postres data:Example of my complete
docker-compose.ymlfile:@lvbn this issue is closed, please open a new issue. Or comment on this open issue that looks related https://github.com/prisma/prisma/issues/21740
I got something similar, but instead of “at localhost:5432” I got “at aws-0-sa-east-1.pooler.supabase.com:5432”.
The full error message looks like this:
`Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma Datasource “db”: PostgreSQL database “postgres”, schema “public” at “aws-0-sa-east-1.pooler.supabase.com:5432”
Error: P1010: User
postgres.xxxwas denied access on the database `postgres.public``This happens when I try to run:
npx prisma migrate dev --name initI appreciate a lot if anyone could help me out!
As I just spent 3 hours on the same issue, I’m also gonna chip in here.
❗️❗️ Make sure that all other Postgres apps are paused! ❗️❗️
I had PostgresSQL for mac running on localhost which was causing
npx prisma db pushto connect to it instead of my docker.I changed
host all all 127.0.0.1/32 identtohost all all 127.0.0.1/32 trustinpg_hba.conffile