Databases

Leash provides managed PostgreSQL databases. When you deploy an app that uses a database, the CLI detects it and offers to create one for you.

Automatic Detection

The CLI detects database dependencies in your package.json, requirements.txt, go.mod, and other manifest files. If it finds PostgreSQL packages, it offers to provision a database.

DependencyLanguage
pgNode.js
prismaNode.js / TypeScript
psycopg / psycopg2Python
pgxGo

Deploy Flow

When a database dependency is detected during deploy, the CLI gives you three choices:

Terminal

$ leash deploy

✓ Detected: flask (python)

⚠ Your app uses PostgreSQL (psycopg)

Options:

[1] Create a Leash database (free with your plan)

[2] Paste your own database URL

[3] Skip — I'll configure it later

Choice (1/2/3): 1

✓ Database created — DATABASE_URL injected

How It Works

  • Each app gets its own isolated PostgreSQL database and user
  • DATABASE_URL is automatically injected as an environment variable
  • Your ORM (Prisma, SQLAlchemy, etc.) creates tables on first connection
  • Daily automated backups with 7-day retention

Database Limits

LimitFreeIndividualProTeam
Max connections10101010
Query timeout30s30s30s30s
Storage50 MB500 MB2 GB10 GB

Common Issues

  • "too many connections" — Use connection pooling (PgBouncer or app-level). Close connections after each request. Max 10 concurrent per app.
  • "canceling statement due to statement timeout" — Query exceeded 30 seconds. Optimize your query, add indexes, or paginate results.
  • "connection refused" — DATABASE_URL only works from apps deployed on Leash. It uses an internal socket connection and is not accessible externally.

Bring Your Own Database

Already using an external database? Choose option [2] during deploy or set the connection string manually.

Set the connection string in your app's Environment tab on the dashboard. Use the appropriate variable name for your database:

Supabase

Set DATABASE_URL to your Supabase connection string.

Neon

Set DATABASE_URL to your Neon connection string.

MongoDB Atlas

Set MONGODB_URI to your Atlas connection string.

Redis (Upstash / Redis Cloud)

Set REDIS_URL to your Redis connection string.