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.
| Dependency | Language |
|---|---|
pg | Node.js |
prisma | Node.js / TypeScript |
psycopg / psycopg2 | Python |
pgx | Go |
Deploy Flow
When a database dependency is detected during deploy, the CLI gives you three choices:
$ 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_URLis 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
| Limit | Free | Individual | Pro | Team |
|---|---|---|---|---|
| Max connections | 10 | 10 | 10 | 10 |
| Query timeout | 30s | 30s | 30s | 30s |
| Storage | 50 MB | 500 MB | 2 GB | 10 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.