Skip to the page

getting started / connecting services

Connecting services

Every service of a project can reach the others. This page covers the private network, the variables 00b5e2 adds for you, opening a service to the internet and connecting two projects.

The private network

Each project has its own private network. Every service reaches the others by name and port: db:5432, cache:6379, api:8080. Nothing on it is reachable from the internet unless the service is open at its address. Sites and APIs are open by default; databases, caches, workers, cron jobs and containers are closed.

A typical project

A site and an API open to the internet, a worker reading a queue, Postgres, Valkey as the queue (Valkey is coming next) and a cron job. The arrows show who talks to whom, all by name inside my-site.

Only web and api answer from the internet. db, cache, mailer and nightly-report are reached by name only.

Variables added for you

When a service uses a database, 00b5e2 injects its connection variables into it: DATABASE_URL for a database named db, or a variable named after it, like ANALYTICS_URL for a database named analytics. In your own variables, reference other services instead of copying values: ${db.url}, ${cache.url}, ${api.internal_url}. References follow renames and password rotations.

variables of mailer
DATABASE_URL   = ${db.url}              # postgres://...@db:5432/db
ANALYTICS_URL  = ${analytics.url}       # a second database
CACHE_URL      = ${cache.url}           # redis://cache:6379
API_URL        = ${api.internal_url}    # http://api:8080

A worker reading a queue

mailer has no port and no address. It waits on a list in cache, the Valkey database used as a queue, and the API pushes jobs into it:

mailer/worker.js
import { createClient } from 'redis'
const queue = createClient({ url: process.env.CACHE_URL })
await queue.connect()
while (true) {
  const job = await queue.blPop('emails', 0)
  await send(JSON.parse(job.element))
}

A cron job calling the API

A cron job runs inside the project, so it calls the API by name, with no public address and no token:

terminal
$ 00b5e2 cron add nightly-report --schedule "0 3 * * *" --command "curl -fsS http://api:8080/reports/nightly"
■ nightly-report added to my-site, every day at 03:00 UTC, nothing to open

Several sites in one project

A project can hold as many sites as it needs. Each has its own address, deploys and logs, and they all share the network, databases and variables of the project:

sites of my-site
my-site.00b5e2.app          web, the main site
docs.my-site.00b5e2.app     docs
admin.my-site.00b5e2.app    admin, calls api:8080 inside

Use a database from outside 00b5e2

Every service has its address reserved. To use db from an app hosted somewhere else, open it. An opened database gets its own port on the shared host, not 5432, because many Postgres and MySQL clients don't send the hostname:

terminal
$ 00b5e2 services open db --allow 203.0.113.0/24
■ open at postgres://db_user:•••@db.my-site.00b5e2.app:31842/db?sslmode=require
■ TLS required, password generated, login attempts limited
  email to the owners: db is open to the internet
$ 00b5e2 services close db
■ closed  db:5432 inside my-site only
defencewhat it does
TLSRequired. Plain connections are refused.
passwordLong and generated, never chosen by hand. Regenerate it in the dash.
login attemptsLimited per address, so the password can't be guessed.
alertAn email to the owners when someone fails many times.
IP allowlistRecommended, optional: --allow takes addresses and ranges.

Inside the project nothing changes: services keep using DATABASE_URL and db:5432 while db is open.

Connecting two projects

Projects never see each other. To let my-site reach a service of another project in the same organisation, allow it:

terminal
$ 00b5e2 network allow --to my-shop
■ my-site reaches my-shop by name: db.my-shop.internal:3306

From the CLI and MCP

climcpwhat it does
00b5e2 services link mailer dblink_serviceGive mailer the variables of db
00b5e2 env lslist_variablesVariables, injected ones included, no secret values
00b5e2 services lslist_servicesServices with kind, address and open or closed
00b5e2 services open dbopen_serviceOpen a service at its address (a database on its own port, with TLS and defences)
00b5e2 services close dbclose_serviceClose a service again
00b5e2 network allow --tonone, on purposeLet one project reach another

What isolation guarantees

Other projects, other organisations and the internet can't reach any closed service, not even another project of yours, until you allow it. Each service runs in its own microVM and each project has its own network. Opening a service only adds its address; it never joins another network.