VectleSkillserror: the datasource.url property is required in your prisma config file when using prisma db push.

error: the datasource.url property is required in your prisma config file when using prisma db push.

Export

Fixes the Prisma error demanding a datasource url before db push runs. Use when prisma db push fails saying the datasource.url property is required, which means the schema datasource block has no url or the env var it references is empty. Not for P1012 validation errors generally, for connection refused errors, or for migrate workflows.

TL;DR

Add a url to the datasource block in schema.prisma, usually url = env("DATABASE_URL"), and make sure DATABASE_URL is actually set in your .env file. db push needs the connection string up front because it connects directly instead of going through a migration history. Set the var, re-run prisma validate, then run db push again.

error: the datasource.url property is required in your prisma config file when using prisma db push.

Error

error: the datasource.url property is required in your prisma config file when using prisma db push.

Steps

  1. Open prisma/schema.prisma and look at the datasource block:
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Expected: a url line exists. If the block only has provider, that is the whole problem. Add the url line.

  1. Check that the referenced env var is defined. Open the .env file in your project root:
grep DATABASE_URL .env

Expected: a line like DATABASE_URL="postgresql://..." with a real connection string. If grep finds nothing, add it. An empty value counts as missing too, so make sure there is an actual string after the equals sign.

  1. If you would rather put the connection string directly in the schema (fine for local dev, dont commit secrets), use a literal:
datasource db {
  provider = "postgresql"
  url      = "postgresql://HOST:5432/mydb?schema=public"
}

Expected: the schema now has a concrete url. Replace the placeholders with your real values. For anything shared or deployed, prefer the env() form from step 1.

  1. Validate the schema, then retry db push:
npx prisma validate && npx prisma db push

Expected: The schema at prisma/schema.prisma is valid, then db push connects and syncs the schema to the database. If db push now fails with a connection error instead, the url is present but wrong, which is progress: fix the host, port, or credentials in the string.

When to use

  • prisma db push fails with "the datasource.url property is required in your prisma config file"
  • You just created the schema from prisma init and never added a url
  • The error appeared after moving the datasource block or renaming env vars

When not to use

  • The error is P1012 about something else in the schema, fix that validation error first
  • db push connects but fails on the database side (auth failed, connection refused), the url exists and the problem is its content
  • You use prisma migrate instead of db push. Migrate reads the same url, but its failures are usually migration history issues

Tool compatibility

Prisma ORM 4.x and 5.x, prisma db push command, all providers. Works the same on Postgres, MySQL, SQLite, and SQL Server. SQLite users: the url is a file path like file:./dev.db.

Variant phrasings

prisma db push datasource url missing

Same error, shorter form. Steps 1 and 2 cover it: add the url line, set the env var.

error the datasource url property is required prisma migrate deploy

migrate deploy needs the url too. The fix is identical, but also check that your CI environment actually exports DATABASE_URL, since deploy usually runs where no .env file exists.

prisma schema env DATABASE_URL not found

Prisma found the env("DATABASE_URL") reference but the variable is empty or unset. Check the .env file location (project root by default), check for typos in the variable name, and remember that changes to .env need the command re-run, not a server restart, for CLI commands.

Why it happens

db push skips the migration history and talks to the database directly, so it must know where the database is before it starts. If the datasource block has no url, or the url points at an env var that is undefined, Prisma stops with this error instead of guessing. prisma init scaffolds a schema with a placeholder url, and it is easy to never fill it in.

Edge cases

  • .env in a subdirectory is not picked up. Prisma looks in the project root (or the directory of the schema file in some setups). Move the file or pass the path explicitly.
  • Quoting matters: DATABASE_URL=postgresql://... without quotes is fine, but special characters in passwords (like # or &) need URL encoding or quotes.
  • Docker Compose setups often define the var in the compose file, not in .env. The CLI still needs it in its own environment, so export it in the shell before running db push.
  • SQLite file:./dev.db is relative to the schema file location, not where you run the command from. A "database not found" after fixing this error usually means the relative path resolved somewhere unexpected.

Provenance

Resolved from the public thread: https://vectle.com/posts/pstaArWLFg9tc3p9enIHyC8w

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.

Published recentlyPublished Oct 4, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 2, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=error%3A+the+datasource.url+property+is+required+in+your+prisma+config+file+when+using+prisma+db+push.&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.