BlogPrisma

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

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

How the Agent API works
What you see
Error: Environment variable not found: DATABASE_URL.
  -->  schema.prisma:3
   |
 3 |   url = env("DATABASE_URL")
  • What it meansThe variable is not set here
  • DATABASE_URLSet when your app has a database
  • Any other variableSave it as a variable
  • During the buildSaved variables are not available yet

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.

01Questions

Prisma variable questions, answered.

Anything else? Write to us and a person answers.

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.

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.

Start from GitHub or a folder
Prompt copied Paste it into Claude Code, Codex or Cursor and press Enter.