P1003: Database `mydb` does not exist on the database server at `YOUR_HOST:5432`.
Fixes Prisma error P1003 'Database does not exist on the database server' by creating the missing database and then running migrations against it. Use when the server is reachable and credentials work but the named database was never created. Not for unreachable servers (P1001) or auth failures (P1000).
TL;DR: The server is fine, the database just was never created. Create it (createdb or your compose db service), then run prisma migrate dev or migrate deploy. P1003 is Prisma telling you the name in your connection string matches nothing.
Error: P1003: Database `mydb` does not exist on the database server at `YOUR_HOST:5432`.Steps
- Confirm the database is really missing:
psql -h YOUR_HOST -U postgres -lqt | cut -d '|' -f 1 | grep -w mydbExpected: no output. If it prints the name, your connection string points at the wrong server.
- Create it. Pick the one that matches your setup:
createdb -h YOUR_HOST -U postgres mydbor start the compose service that owns it:
docker compose up -d dbExpected: the name now appears in the database list.
- Build the schema inside it:
npx prisma migrate deploy Expected: All migrations have been successfully applied. P1003 is gone.
When to use
- The exact code is P1003 and you can connect to the server itself
- Fresh setups, new branches, or restored servers where the database was never created
When not to use
- P1001: you cannot reach the server at all
- P1000: the server rejects your credentials before the database name even matters
Compatibility
Prisma Client and Migrate 4.x through 6.x. PostgreSQL, MySQL, SQL Server.
Variant phrasing: P1003 in tests that use a separate test database
Create the test database in your test setup script before migrations run, not after.
Variant phrasing: P1003 after dropping the database by hand
Recreate it and re-run migrate deploy; there is no shortcut around the missing database.
Why it happens
Prisma connects to the server first, then selects the database named in the connection string. migrate deploy will not create the database itself (only the schema inside it), so a name that was never created fails with P1003 every time.
Edge cases
- Case sensitivity:
MyDBandmydbare different names on most servers; match the connection string exactly. - Managed providers usually create a default database for you; P1003 there means a typo in the name.
- If
createdbsays permission denied, your role lacks CREATEDB; ask the DBA or use a superuser.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.