Prisma Error P3000: Failed to Create Database

Prisma error P3000 (Failed to Create Database) explained: what it means, why it happens, and how to fix it — with copy-paste code examples.

Error code P3000 Prisma Last verified 2026-08-19

Quick Answer

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

Error code: P3000
Official name: Failed to Create Database
Service: Prisma

What does this error mean?

Failed to create database: {database_error}

Common Causes

How to Fix

  1. Look at the {database_error} in the message: it names the underlying permission or connection problem
  2. PostgreSQL: grant `CREATEDB` to the user (`ALTER ROLE <user> CREATEDB;`) or use an admin role
  3. MySQL: ensure the user has the CREATE privilege on the target schema
  4. If the platform manages databases itself, create the empty database in its console and retry
  5. Confirm DATABASE_URL uses the right host/port and that the database name is a fresh one

Code Examples

Grant database creation sql
ALTER ROLE your_user CREATEDB;

Lets the app user create the database Prisma needs; run as a superuser or admin.

Create it manually once bash
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.

Framework-Specific Fixes

prisma-cli

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)
github-actions

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
nestjs

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

You Might Also Like

Frequently Asked Questions

Why am I seeing Prisma error P3000?

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.

How do I fix Prisma error P3000?

Look at the {database_error} in the message: it names the underlying permission or connection problem.

Which frameworks have documented fixes for error P3000?

This page documents fixes for: prisma-cli, github-actions, nestjs.

Official Sources

This page is based on the official Prisma documentation linked below and adds practical troubleshooting guidance on top.