# Prisma: Environment variable not found: DATABASE_URL How to fix it.

URL: https://antideploy.com/blog/prisma-environment-variable-not-found

Prisma read a variable named in your schema, and it was not set where the command ran. Here is where each one comes from.

**What you see**

```
Error: Environment variable not found: DATABASE_URL.
  -->  schema.prisma:3
   |
 3 |   url = env("DATABASE_URL")
```

## At a glance

- **What it means**: The variable is not set here
- **DATABASE_URL**: Set when your app has a database
- **Any other variable**: Save it as a variable
- **During the build**: Saved variables are not available yet

Published 7 October 2026. Facts checked 7 October 2026. 1 min read.

## What it means

Your Prisma schema reads values with `env("NAME")`. A command needed that value and it was not set in the place the command ran. The message names the variable.

## How to fix it

- **If it is `DATABASE_URL`.** When your app has an Antideploy database, the variable is set for the migration step and for the running app. If your app has none, ask your agent to add a database, or save your own `DATABASE_URL` as a variable.
- **If it is another variable,** such as `DIRECT_URL`. Save it as a variable for the app and redeploy.
- **If it fails during the image build.** Variables you save are available when the app runs and during the migration step, not while the image is being built. Commands that need the database, such as `prisma migrate` or a query, belong in the migration step or the running app, not in a build script. `prisma generate` itself does not need the database.

## Steps

### 1. Find which command raised it

The log shows the command above the message.

### 2. Set or create what is missing

Create the database or save the variable.

### 3. Deploy again

A failed deploy never counts against your plan.

## Prisma variable questions, answered.

Anything else? Write to us and a person answers.

[support@antideploy.com](mailto:support@antideploy.com)

### Do I need to set DATABASE_URL myself?

Not when your app has an Antideploy database. A `DATABASE_URL` you set yourself always wins, so a project pointed at Supabase or your own Neon project keeps working.

### Can I see the value after I save it?

No. Values are write-only. If you lose one, set it again.

### Does this failed deploy cost anything?

No. Failed deploys never count against your plan.

## More guides, and the platform.

Each platform page covers one part of Antideploy: what it does, where it stops and the questions people ask. [See the whole platform](https://antideploy.com/platform), or [all the guides](https://antideploy.com/blog).

- [How to add a Postgres database to your app](https://antideploy.com/blog/how-to-add-a-postgres-database-to-your-app): Ask your agent. A Postgres 17 database is created beside your app and DATABASE_URL is set.
- [How to set environment variables and secrets](https://antideploy.com/blog/how-to-set-environment-variables-and-secrets): Encrypted and write-only. What you set, what is filled in for you, and how a change reaches the app.
- [sh: prisma: not found during prisma generate](https://antideploy.com/blog/prisma-generate-command-not-found): The build ran prisma generate and prisma is not installed. Add it at the same version as @prisma/client.

- [Environment variables](https://antideploy.com/platform/environment-variables)
- [Database](https://antideploy.com/platform/database)
- [Deployments](https://antideploy.com/platform/deployments)

Facts on this page were checked against the live platform on 7 October 2026.

## Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

To set this up, give your coding agent this sentence:

```text
Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.
```
