question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

migrate deploy: Error: P1010: User `user` was denied access on the database `db.public`

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
herbievinecommented, Jul 31, 2022

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:

version: '3.8'
services:
  postgres:
    image: postgres:13
    restart: always
    container_name: my-db
    ports:
      - "5555:5432"
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=postgres
    volumes:
      - my-db:/var/lib/postgresql/data
volumes:
  my-db:

Then connect to it using postgresql://postgres:postgres@localhost:5555/my-db?schema=public

Should work then!

3reactions
ICiscoStucommented, May 18, 2022

Does npx prisma db pull work?

no it does not, the error I get is the one posted above…

npx prisma db pull
Environment variables loaded from .env
Datasource "db": PostgreSQL database "postgres", schema "public" at "localhost:5432"

✖ Introspecting based on datasource defined in prisma/schema.prisma

Error: P1010

User 'postgres' was denied access on the database 'postgres.public'```
Read more comments on GitHub >

github_iconTop Results From Across the Web

Prism V2 access denied to postgres database - Stack Overflow
When i run npx prisma migrate dev all i get is Error: P1010: User 'johndoe' was denied access on the database 'db.public' ....
Read more >
Error message reference - Prisma
Prisma Client, Migrate, Introspection error message reference. ... P1010. "User {database_user} was denied access on the database {database_name} " ...
Read more >
How to solve "User `postgres` was denied access on the ...
When I called some functions (example prisma.users.findAll()) in docker container I have error User 'postgres' was denied access on the database 'my_db.public' ...
Read more >
Permission denied in Postgres [duplicate]
You've granted CREATE , CONNECT , and TEMPORARY privileges on the database to myuser but you haven't granted SELECT and INSERT table privileges...
Read more >
Easy way to fix permission denied for database Postgres error
The permission denied for database Postgres error occurs due to the lack of certain privileges like CONNECT, CREATE, DEFAULT and so on.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found