Prisma says P1000: the database credentials are not valid
P1000: Authentication failed against database server at `localhost`, the provided database credentials for `postgres` are not valid.Short answer
P1000 means the server was reached but rejected the user and password in DATABASE_URL. With a Postgres container the usual reasons are: the volume was created with an older POSTGRES_PASSWORD, the password has characters that need percent-encoding, or Prisma reads a different .env file than the one you edited.
Fix it fast
1Find out which cause you have
Log in with psql using the exact user and password from DATABASE_URL, outside Prisma. If this fails too, the problem is the database side; if it works, look at how Prisma reads the URL.
grep -n DATABASE_URL .env docker compose exec db psql -U postgres -c "select current_user;"2Match what you see, then jump to its fix
- 1
You changed POSTGRES_PASSWORD in compose.yaml, restarted, and P1000 stayed.The volume still holds an older passwordFix - 2
The password has characters such as @, :, / or # and the same text works in psql.The password contains characters that are not URL-encodedFix - 3
The URL in the file you changed is right, yet the error names an old user or host.Prisma reads a different .env than the one you editedFix
- 1
What does the error look like?
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`.
Cause 1 of 3
The volume still holds an older password
1Check
The image applies POSTGRES_PASSWORD only when it starts with an empty data directory. A volume from an earlier run keeps whatever password it was first created with, so the new value in the file is ignored.
docker volume ls
docker compose config | grep -n -A3 volumes2Fix
Either set the role's password inside the running database to match DATABASE_URL, or, if the data is disposable, remove the volume so the container initialises again with the current value.
# keep the data: change the password in place
docker compose exec db psql -U postgres -c "ALTER ROLE postgres WITH PASSWORD 'new-password';"
# throw the data away and start clean
docker compose down -v
docker compose up -d3Verify
Run a Prisma command that opens a connection.
npx prisma migrate statusConfirmed by hub.docker.com
Cause 2 of 3
The password contains characters that are not URL-encoded
1Check
Prisma requires percent-encoding of special characters in any part of a PostgreSQL connection URL, passwords included. An unencoded @ ends the password early.
grep -n DATABASE_URL .env2Fix
Encode the password in the URL (for example @ becomes %40), or choose a password without such characters.
# password: p@ss:word
DATABASE_URL="postgresql://postgres:p%40ss%3Aword@localhost:5432/mydb"3Verify
The same Prisma command now connects.
npx prisma migrate statusConfirmed by prisma.io
Cause 3 of 3
Prisma reads a different .env than the one you edited
1Check
The Prisma CLI looks for .env in several places in order: the project root, the schema folder, the path from package.json and ./prisma. A second file in one of these, or a variable already set in your shell, can win over the one you changed. Prisma Client itself only loads the root .env on its own.
find . -name ".env*" -not -path "./node_modules/*"
env | grep DATABASE_URL2Fix
Keep one definition of DATABASE_URL, remove stale copies, and unset any old value in the shell.
unset DATABASE_URL
npx prisma migrate status3Verify
The command connects without P1000.
npx prisma migrate statusConfirmed by prisma.io
How do I stop it coming back?
- Treat POSTGRES_PASSWORD as an initial value only; change an existing password with ALTER ROLE or psql's \password.
- Generate passwords from letters and digits, or encode them before putting them in a URL.
- Keep DATABASE_URL in one .env file and load it the same way in the CLI and in the app.
- Test every new URL with psql first, so Prisma is never the first thing to try it.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Databases
The Postgres container rejects the password you set in POSTGRES_PASSWORD
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: password authentication failed for user "postgres"
The official Postgres image reads POSTGRES_PASSWORD only when it creates a new database cluster in an empty data directory.
2 causes, each with a fixDatabases
Prisma says it can't reach the database server, but the database is up
Please make sure your database server is running at `localhost`:`5432`.
P1001 is Prisma's catch-all for any failed connection, even a wrong password, so do not trust the label.
4 causes, each with a fixDatabases
Node.js in Docker Compose cannot find mysql2/promise
The app works on the host but fails after docker compose up
mysql2/promise is a path inside the mysql2 package.
2 causes, each with a fixDatabases
mongodb-memory-server will not start under Jest or in Docker
NoSystemBinaryFoundError
When mongodb-memory-server fails to start, the real reason is hidden behind a generic message.
4 causes, each with a fixDatabases
Django cannot connect to PostgreSQL: connection refused on port 5432, locally or in Docker
Is the server running on that host and accepting TCP/IP connections?
Connection refused means nothing accepted the connection at the host and port Django used.
4 causes, each with a fixDatabases
A container cannot resolve the name of its database container
php_network_getaddresses: getaddrinfo failed
127.0.0.11 is Docker's own DNS server for custom networks.
3 causes, each with a fix