Prisma error P3000 (Failed to Create Database) explained: what it means, why it happens, and how to fix it — with copy-paste code examples.
Look at the {database_error} in the message: it names the underlying permission or connection problem. If that does not apply, postgreSQL: grant `CREATEDB` to the user (`ALTER ROLE <user> CREATEDB;`) or use an admin role — the full checklist is below.
Error code: P3000
Official name: Failed to Create Database
Service: Prisma
Failed to create database: {database_error}
ALTER ROLE your_user CREATEDB;
Lets the app user create the database Prisma needs; run as a superuser or admin.
psql -U postgres -c 'CREATE DATABASE myapp_dev;'
npx prisma migrate dev
If the platform forbids programmatic creation, create the empty database once and let migrate work inside it.
Fix the connection or grant, then re-run migrate dev so Prisma can create the database.
npx prisma migrate dev
# if CREATE DATABASE is denied:
# ALTER ROLE <user> CREATEDB; (postgres)
Create the database in the service setup step before migrate, not inside migrate.
- run: createdb myapp_dev --user postgres
- run: npx prisma migrate dev --skip-generate
Document the one-time database bootstrap (CREATE DATABASE) outside the app so migrate only ever alters it.
# docs/setup.md
# one-time: psql -U admin -c 'CREATE DATABASE myapp_dev;'
# then: npx prisma migrate dev
Most often this happens when the database user has no CREATE DATABASE privilege, or when the DATABASE_URL points to a server that is unreachable or a database name the server refuses to create.
Look at the {database_error} in the message: it names the underlying permission or connection problem.
This page documents fixes for: prisma-cli, github-actions, nestjs.
Recommendations are editorial — DB Error Reference takes no payment or affiliate fees for tool listings.
This page is based on the official Prisma documentation linked below and adds practical troubleshooting guidance on top.