User was denied access on the database `postgres`
The application cannot connect to the database.
Commands like
prisma migrate dev, prisma studio, and prisma db pull work.
4 Replies
You selected the bot's instantaneous insights. Let me compile your answer right away!
The error "User was denied access on the database
The CLI commands may be connecting to a different PostgreSQL instance than your application. This often happens if you have multiple PostgreSQL servers running (e.g., one via Docker and another installed locally). The CLI might connect to the correct one, but your app connects to another, leading to access issues. Make sure all Postgres instances except the one you intend to use are stopped. Users have resolved this by quitting other local Postgres instances (like Postgres.app or pgAdmin) when using Docker, so only the intended instance is running migrate deploy: Error: P1010. 2. Connection String Issues
Double-check that your application and CLI are using the exact same DATABASE_URL. Even a small difference (like using localhost vs. 127.0.0.1, or a different port) can cause this. Also, ensure the user and password in the connection string are correct and have the necessary permissions migrate schema into postgresql and get Error P1010. 3. pg_hba.conf Configuration
If you are using peer authentication or have restrictive settings in your pg_hba.conf, the CLI and your app may be treated differently. Updating pg_hba.conf to allow trusted connections for localhost can resolve this. For example, change: to and restart PostgreSQL migrate deploy: Error: P1010. 4. Environment Variables in Production
If your app is running in a different environment (e.g., Docker, production server), ensure the environment variables are loaded correctly and match your local setup. Summary:
The issue is almost always due to a mismatch in database connection details or running multiple Postgres instances. Ensure your app and CLI use the same connection string and only one Postgres instance is running. If the problem persists, review your pg_hba.conf settings. If you need more specific help, please provide your DATABASE_URL and details about your environment setup. š¤ Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
postgres" (Prisma error code P1010) during runtime, while commands like prisma migrate dev, prisma studio, and prisma db pull work, typically points to a difference in how your application and the CLI commands are connecting to the database.
Based on the knowledge sources, here are the most common causes and solutions:
1. Different Database ConnectionsThe CLI commands may be connecting to a different PostgreSQL instance than your application. This often happens if you have multiple PostgreSQL servers running (e.g., one via Docker and another installed locally). The CLI might connect to the correct one, but your app connects to another, leading to access issues. Make sure all Postgres instances except the one you intend to use are stopped. Users have resolved this by quitting other local Postgres instances (like Postgres.app or pgAdmin) when using Docker, so only the intended instance is running migrate deploy: Error: P1010. 2. Connection String Issues
Double-check that your application and CLI are using the exact same DATABASE_URL. Even a small difference (like using localhost vs. 127.0.0.1, or a different port) can cause this. Also, ensure the user and password in the connection string are correct and have the necessary permissions migrate schema into postgresql and get Error P1010. 3. pg_hba.conf Configuration
If you are using peer authentication or have restrictive settings in your pg_hba.conf, the CLI and your app may be treated differently. Updating pg_hba.conf to allow trusted connections for localhost can resolve this. For example, change: to and restart PostgreSQL migrate deploy: Error: P1010. 4. Environment Variables in Production
If your app is running in a different environment (e.g., Docker, production server), ensure the environment variables are loaded correctly and match your local setup. Summary:
The issue is almost always due to a mismatch in database connection details or running multiple Postgres instances. Ensure your app and CLI use the same connection string and only one Postgres instance is running. If the problem persists, review your pg_hba.conf settings. If you need more specific help, please provide your DATABASE_URL and details about your environment setup. š¤ Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Same DATABASE_URL
prisma.config.ts
@Prisma AI Help Raw query failed. Code:
28000. Message: no pg_hba.conf entry for host "", user "postgres", database "postgres", no encryptionAre you running postgres locally or are you using a managed postgres offering?
PostgreSQL running on AWS RDS.
I'm using Tailscale to connect into my VPC. It has been confirmed that the connection is possible through DBeaver.