Managed databases

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 db

      02

      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:5432

      03

      Query from your laptop

      Open a local tunnel for psql, a GUI client or a one-off script.

      slasha services proxy db --port 5432

      Service 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
      Managed databases
      AppsstorefrontServicesdb
      dbPostgreSQL 17Running

      CPU

      1.8%

      Memory

      182 MiB

      Volume

      1.2 GB

      From your app

      DATABASE_URL is injected into storefront automatically. Or reference any value:

      DATABASE_URL=${{ db.DATABASE_URL }}
      From your machine
      $ slasha services proxy db

      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
      Environment variables
      storefront · Environment
      DATABASE_URL${{ db.DATABASE_URL }}
      REDIS_URL${{ cache.DATABASE_URL }}
      UPLOAD_DIR${{ SLASHA.managed_data_path }}/uploads
      LOG_LEVELinfo

      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
      Connecting to a database
      Internet
      slasha-proxy · :443

      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-secret hides the password in the printed string
      • Idle tunnels close after 30 minutes
      Service commands

      ❯ 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?
      PostgreSQL 17, 16, 15, 14 and 13; MySQL 9.0, 8.4 and 8.0; MongoDB 8.0, 7.0 and 6.0; Redis 7.4, 7.2 and 7.0. The newest is the default. You can pick another with --version or in the dashboard. See Databases.
      Can I connect with a GUI client?
      Yes. Run 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?
      Slasha only sets 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?
      No. Each service is a single container with a persistent volume on the same server as your app. That’s enough for most apps. Add scheduled backups to S3-compatible storage so you don’t lose data if you lose the server.
      Can I use another engine or my own image?
      Managed services only support these four engines. You can run anything else as its own app, for example from a Dockerfile, but Slasha won’t manage its credentials or backups for you.
      Where are the credentials stored?
      In Slasha’s database, encrypted with your server’s 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 features

      Run your databases on your own server

      Run Postgres, MySQL, MongoDB and Redis on a server you already pay for.

      $curl -fsSL https://slasha.com/setup.sh | bash