Add a database
in one command
Run PostgreSQL, MySQL, MongoDB or Redis next to your app. Slasha creates the credentials, sets DATABASE_URL and keeps the database off the internet.
Version
Memory 512 MiB
❯
SUCCESS: Service provisioning started.
·
Generated on the service
Set on storefront
Backups
Connection string your app sees
The host is the service name on the app’s private network.
How it works
How to add a database
No connection strings to copy, no ports to open, no separate bill.
01
Create it
Pick an engine and a name. Slasha creates passwords and starts it with a persistent volume.
slasha services provision postgresql db02
Deploy
On the next deploy, your app gets a DATABASE_URL pointing at the service. Redis also sets REDIS_URL.
slasha deploy
# DATABASE_URL=postgres://…@db:543203
Query from your laptop
Open a local tunnel for psql, a GUI client or a one-off script.
slasha services proxy db --port 5432Service page
One page for each database
Each service has a page with live CPU, memory and volume usage, logs and backups. Restart, redeploy or stop it there or from the CLI.
- Statuses: Provisioning, Running, Stopped, Failed
- Service logs with
slasha services logs db -f - Connection details for your app and your laptop
CPU
1.8%
Memory
182 / 512 MiB
Volume
1.2 GB
DATABASE_URL is injected into storefront automatically. Or reference any value:
Tunnels over HTTPS. The database port is never opened to the internet.
References
Reference values instead of copying them
Reference a value instead of pasting it: ${{ db.POSTGRES_PASSWORD }}. References are filled in at release, so the app always gets current values.
${{ db.DATABASE_URL }},${{ cache.REDIS_PASSWORD }}, any service var${{ db.service_name }}gives you the hostname- Env values are stored encrypted
Private network
Your database isn’t on the internet
Each app gets its own Docker network. Services join it and are reached by name, like db:5432. Only your web process is reachable through the proxy.
- Database ports aren’t published
- Each app’s services are isolated from other apps
- Workers and cron jobs use the same hostnames
storefront network
web.0
receives traffic
worker.0
internal only
db:5432
PostgreSQL 17
cache:6379
Redis 7.4
No ports published to the host
Tunnel
Connect from your laptop through a tunnel
slasha services proxy opens a local port and tunnels it over a logged-in WebSocket to the database. It prints a connection string you can paste.
- Pick a port with
-p, or let it choose a free one --no-secrethides the password in the printed string- Idle tunnels close after 30 minutes
❯ slasha services proxy db --port 5432
✓ Tunneling db (PostgreSQL)
Listening on: 127.0.0.1:5432
Press Ctrl-C to stop.
❯ psql -h 127.0.0.1 -U postgres
postgres=# select count(*) from orders;
count
-------
18204
postgres=#
More details
Generated passwords
32 random characters, created with the service.
Stored encrypted
Service credentials are encrypted with your server’s key.
Persistent volumes
Data survives restarts, redeploys and server reboots.
Redis with AOF
Redis with a password, saving data to an append-only file.
Scheduled backups
Postgres, MySQL and MongoDB dumps to disk or S3.
Service logs
Live and searchable, same as your app’s logs.
Restart & redeploy
Restart a service without touching your app.
Scoped access
Only members with Manage Services can change or tunnel in.
Questions about databases
Have another question? Ask on GitHub.
Which databases and versions can I run?
--version or in the dashboard. See Databases.Can I connect with a GUI client?
slasha services proxy db and point the client at the 127.0.0.1 address it prints. The tunnel uses your Slasha login, so you never have to open the database port to the internet. See Connecting.I have two databases. Which one gets DATABASE_URL?
DATABASE_URL automatically if you haven’t set it yourself, and with several services the first one wins. To choose, set it yourself with a reference such as DATABASE_URL=${{ db.DATABASE_URL }} and ANALYTICS_URL=${{ events.DATABASE_URL }}.Is this a replicated, high-availability cluster?
Can I use another engine or my own image?
Where are the credentials stored?
SLASHA_KEY. Passwords are generated as 32 random characters when the service is created. You can see them in the service’s env, or with slasha services env db list.Other features
All featuresRun your databases on your own server
Run Postgres, MySQL, MongoDB and Redis on a server you already pay for.