Errors reference

This page describes Prisma exceptions and error codes. For more information about working with exceptions and error codes, see Handling exceptions and errors .

Prisma Client error types

Prisma Client throws different kinds of errors. The following lists the exception types, and their documented data fields:

PrismaClientKnownRequestError

Prisma Client throws a PrismaClientKnownRequestError exception if the query engine returns a known error related to the request - for example, a unique constraint violation.

PropertyDescription
codeA Prisma-specific error code.
metaAdditional information about the error - for example, the field that caused the error: { target: [ 'email' ] }
messageError message associated with error code.
clientVersionVersion of Prisma Client (for example, 2.19.0)

PrismaClientUnknownRequestError

Prisma Client throws a PrismaClientUnknownRequestError exception if the query engine returns an error related to a request that does not have an error code.

PropertyDescription
messageError message associated with error code.
clientVersionVersion of Prisma Client (for example, 2.19.0)

PrismaClientRustPanicError

Prisma Client throws a PrismaClientRustPanicError exception if the underlying engine crashes and exits with a non-zero exit code. In this case, the Prisma Client or the whole Node process must be restarted.

PropertyDescription
messageError message associated with error code.
clientVersionVersion of Prisma Client (for example, 2.19.0)

PrismaClientInitializationError

Prisma Client throws a PrismaClientInitializationError exception if something goes wrong when the query engine is started and the connection to the database is created. This happens either:

  • When prisma.$connect() is called OR
  • When the first query is executed

Errors that can occur include:

  • The provided credentials for the database are invalid
  • There is no database server running under the provided hostname and port
  • The port that the query engine HTTP server wants to bind to is already taken
  • A missing or inaccessible environment variable
  • The query engine binary for the current platform could not be found (generator block)
PropertyDescription
errorCodeA Prisma-specific error code.
messageError message associated with error code.
clientVersionVersion of Prisma Client (for example, 2.19.0)

PrismaClientValidationError

Prisma Client throws a PrismaClientValidationError exception if validation fails - for example:

  • Missing field - for example, an empty data: {} property when creating a new record
  • Incorrect field type provided (for example, setting a Boolean field to "Hello, I like cheese and gold!")
PropertyDescription
messageError message associated with error code.

Error codes

Common

P1000

"Authentication failed against database server at {database_host}, the provided database credentials for {database_user} are not valid. Please make sure to provide valid database credentials for the database server at {database_host}."

P1001

"Can't reach database server at {database_host}:{database_port} Please make sure your database server is running at {database_host}:{database_port}."

P1002

"The database server at {database_host}:{database_port} was reached but timed out. Please try again. Please make sure your database server is running at {database_host}:{database_port}. "

P1003

"Database {database_file_name} does not exist at {database_file_path}"

"Database {database_name}.{database_schema_name} does not exist on the database server at {database_host}:{database_port}."

"Database {database_name} does not exist on the database server at {database_host}:{database_port}."

P1008

"Operations timed out after {time}"

P1009

"Database {database_name} already exists on the database server at {database_host}:{database_port}"

P1010

"User {database_user} was denied access on the database {database_name}"

P1011

"Error opening a TLS connection: {message}"

P1012

"{full_error}"

Possible errors:

  • "Argument {} is missing."
  • "Function {} takes {} arguments, but received {}."
  • "Argument {} is missing in attribute @{}."
  • "Argument {} is missing in data source block {}."
  • "Argument {} is missing in generator block {}."
  • "Error parsing attribute @{}: {}"
  • "Attribute @{} is defined twice."
  • "The model with database name {} could not be defined because another model with this name exists: {}"
  • "{} is a reserved scalar type name and can not be used."
  • "The {} {} cannot be defined because a {} with that name already exists."
  • "Key {} is already defined in {}."
  • "Argument {} is already specified as unnamed argument."
  • "Argument {} is already specified."
  • "No such argument.""
  • "Field {} is already defined on model {}."
  • "Field {} in model {} can't be a list. The current connector does not support lists of primitive types."
  • "The index name {} is declared multiple times. With the current connector index names have to be globally unique."
  • "Value {} is already defined on enum {}."
  • "Attribute not known: @{}."
  • "Function not known: {}."
  • "Datasource provider not known: {}."
  • "shadowDatabaseUrl is the same as url for datasource {}. Please specify a different database as shadow database."
  • "The preview feature {} is not known. Expected one of: {}"
  • "{} is not a valid value for {}."
  • "Type {} is neither a built-in type, nor refers to another model, custom type, or enum."
  • "Type {} is not a built-in type."
  • "Unexpected token. Expected one of: {}"
  • "{}"
  • "{}"
  • "{}"
  • "Environment variable not found: {}."
  • "Expected a {} value, but received {} value {}."
  • "Expected a {} value, but failed while parsing {}: {}."
  • "Error validating model {}: {}"
  • "Error validating field {} in model {}: {}"
  • "Error validating datasource {datasource}: {message}""
  • "Error validating enum {}: {}"
  • "Error validating: {}"

P1013

"The provided database string is invalid. {details}"

P1014

"The underlying {kind} for model {model} does not exist."

P1015

"Your Prisma schema is using features that are not supported for the version of the database.
Database version: {database_version}
Errors:
{errors}"

P1016

"Your raw query had an incorrect number of parameters. Expected: {expected}, actual: {actual}."

P1017

"Server has closed the connection."

Prisma Client (Query Engine)

P2000

"The provided value for the column is too long for the column's type. Column: {column_name}"

P2001

"The record searched for in the where condition ({model_name}.{argument_name} = {argument_value}) does not exist"

P2002

"Unique constraint failed on the {constraint}"

P2003

"Foreign key constraint failed on the field: {field_name}"

P2004

"A constraint failed on the database: {database_error}"

P2005

"The value {field_value} stored in the database for the field {field_name} is invalid for the field's type"

P2006

"The provided value {field_value} for {model_name} field {field_name} is not valid"

P2007

"Data validation error {database_error}"

P2008

"Failed to parse the query {query_parsing_error} at {query_position}"

P2009

"Failed to validate the query: {query_validation_error} at {query_position}"

P2010

"Raw query failed. Code: {code}. Message: {message}"

P2011

"Null constraint violation on the {constraint}"

P2012

"Missing a required value at {path}"

P2013

"Missing the required argument {argument_name} for field {field_name} on {object_name}."

P2014

"The change you are trying to make would violate the required relation '{relation_name}' between the {model_a_name} and {model_b_name} models."

P2015

"A related record could not be found. {details}"

P2016

"Query interpretation error. {details}"

P2017

"The records for relation {relation_name} between the {parent_name} and {child_name} models are not connected."

P2018

"The required connected records were not found. {details}"

P2019

"Input error. {details}"

P2020

"Value out of range for the type. {details}"

P2021

"The table {table} does not exist in the current database."

P2022

"The column {column} does not exist in the current database."

P2023

"Inconsistent column data: {message}"

P2024

"Timed out fetching a new connection from the connection pool. (More info: http://pris.ly/d/connection-pool, Current connection limit: {connection_limit})"

P2025

"An operation failed because it depends on one or more records that were required but not found. {cause}"

P2026

"The current database provider doesn't support a feature that the query used: {feature}"

P2027

"Multiple errors occurred on the database during query execution: {errors}"

Prisma Migrate (Migration Engine)

P3000

"Failed to create database: {database_error}"

P3001

"Migration possible with destructive changes and possible data loss: {migration_engine_destructive_details}"

P3002

"The attempted migration was rolled back: {database_error}"

P3003

"The format of migrations changed, the saved migrations are no longer valid. To solve this problem, please follow the steps at: https://pris.ly/d/migrate"

P3004

"The {database_name} database is a system database, it should not be altered with prisma migrate. Please connect to another database."

P3005

"The database schema for {database_name} is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline"

P3006

"Migration {migration_name} failed to apply cleanly to the shadow database.
{error_code}Error:
{inner_error}"

P3007

"Some of the requested preview features are not yet allowed in migration engine. Please remove them from your data model before using migrations. (blocked: {list_of_blocked_features})"

P3008

"The migration {migration_name} is already recorded as applied in the database."

P3009

"migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
{details}"

P3010

"The name of the migration is too long. It must not be longer than 200 characters (bytes)."

P3011

"Migration {migration_name} cannot be rolled back because it was never applied to the database. Hint: did you pass in the whole migration name? (example: \"20201207184859_initial_migration\")"

P3012

"Migration {migration_name} cannot be rolled back because it is not in a failed state."

P3013

"Datasource provider arrays are no longer supported in migrate. Please change your datasource to use a single provider. Read more at https://pris.ly/multi-provider-deprecation"

P3014

"Prisma Migrate could not create the shadow database. Please make sure the database user has permission to create databases. More info: https://pris.ly/d/migrate-shadow. Original error: {error_code}
{inner_error}"

P3015

"Could not find the migration file at {migration_file_path}. Please delete the directory or restore the migration file."

P3016

"The fallback method for database resets failed, meaning Migrate could not clean up the database entirely. Original error: {error_code}
{inner_error}"

P3017

"The migration {migration_name} could not be found. Please make sure that the migration exists, and that you included the whole name of the directory. (example: \"20201207184859_initial_migration\")"

P3018

"A migration failed to apply. New migrations can not be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve

Migration name: {migration_name}

Database error code: {database_error_code}

Database error:
{database_error} "

P3019

"The datasource provider {provider} specified in your schema does not match the one specified in the migration_lock.toml, {expected_provider}. Please remove your current migration directory and start a new migration history with prisma migrate dev. Read more: https://pris.ly/d/migrate-provider-switch"

P3020

"The automatic creation of shadow databases is disabled on Azure SQL. Please set up a shadow database using the shadowDatabaseUrl datasource attribute.
Read the docs page for more details: https://pris.ly/d/migrate-shadow"

prisma db pull (Introspection Engine)

P4000

"Introspection operation failed to produce a schema file: {introspection_error}"

P4001

"The introspected database was empty: {connection_string}"

P4002

"The schema of the introspected database was inconsistent: {explanation}"

Edit this page on GitHub