VectleSkillsEnvironment variable not found: DATABASE_URL.

Environment variable not found: DATABASE_URL.

Export

Fixes the Prisma error 'Environment variable not found: DATABASE_URL' by ensuring the DATABASE_URL is actually present in the environment where the Prisma command runs, commonly a CI job or Docker container that never received it. Use when Prisma validate, migrate, or generate fails with this exact message. Not for malformed URL errors or P1012 protocol errors.

TL;DR: The DATABASE_URL value is not reaching the shell that runs Prisma. Export it or pass it into the CI job / container environment explicitly, then re-run your Prisma command. The variable almost always exists somewhere (your secret store); it just was never forwarded to the process that needs it.

error: Environment variable not found: DATABASE_URL.

Steps

  1. Confirm the variable is missing in the failing environment:
   echo "${DATABASE_URL:+set}"

Expected: empty output. If it prints set, your shell sees it and the real problem is elsewhere.

  1. In CI (GitHub Actions and similar), forward the secret into the job:
   jobs:
     deploy:
       env:
         DATABASE_URL: ${{ secrets.DATABASE_URL }}

Expected: the Prisma step in the next run no longer fails at the env check.

  1. In Docker / compose, declare it where the Prisma command runs:
   services:
     app:
       environment:
         - DATABASE_URL=${DATABASE_URL}

Expected: docker compose exec app npx prisma validate loads the config without the env error.

  1. Re-run the original command (npx prisma migrate deploy, prisma generate, etc.).

Expected: the env error is gone. A different error (bad password, unreachable host) means the variable now arrives but its value is wrong.

When to use

  • The exact message is Environment variable not found: DATABASE_URL on validate, migrate, generate, or db push
  • The failure appears in CI, Docker, or any environment other than your local machine

When not to use

  • The message complains the URL must start with a protocol (P1012): that means the var exists but its value is malformed
  • Local shell: if your own terminal lacks it, just export it or fix your .env loader instead of touching CI

Compatibility

Prisma CLI 4.x through 7.x. Any CI provider or container runtime.

Variant phrasing: Environment variable not found: DIRECT_URL

Same shape, different variable. Forward DIRECT_URL the same way.

Variant phrasing: error appears during prisma generate in a Docker build

Build-time args do not become runtime env automatically. Pass DATABASE_URL as a build arg and also as a runtime environment entry.

Why it happens

Prisma reads connection strings from env() in the config or from the process environment. Secrets stored in a CI provider or orchestrator are not injected into a job or container unless the pipeline config forwards them. So the variable can be perfectly configured in your dashboard and still invisible to the Prisma process.

Edge cases

  • Prisma 7 with prisma.config.ts skips auto-loading .env; add the dotenv import or export the variable for real in that shell.
  • Shell quoting: a value containing # or ! gets mangled by unquoted assignment; quote it.
  • If the error persists after forwarding, check for a typo in the variable name (DATABASEURL vs DATABASEURLS).

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 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 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=Environment+variable+not+found%3A+DATABASE_URL.&type=skill'

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