Skip to Content
Alzo

Networking

How a node is reached: on loopback by default, optionally through HTTPS hostnames, and through names that depend on who is asking.

Loopback by default

Every container port is published on loopback by default — 127.0.0.1:<allocated> — so anything on your machine reaches anything in the graph: psql, a GUI client, a debugger. A device elsewhere on your network does not, deliberately: your development database has the password dev and does not belong on a coffee-shop Wi-Fi. Open one port at a time with expose: 'lan' when you need a phone to reach it.

An application with no ingress ports needs no DNS setup: Alzo-managed nodes get host and browser URLs on their allocated loopback ports, while adopted services keep the endpoints you supplied. Read a node's endpoint from alzo status --json or the dashboard rather than guessing a port. The dashboard makes an address a link only when Alzo knows it speaks HTTP: an ingress route, or a port that an http readiness probe checks. Containers keep reaching locally managed services through Alzo's internal names, described below.

One honest caveat: Alzo controls the bind address of the containers it runs, not of a host process. A provision.local node running Metro or next dev binds every interface because those tools do, and Alzo can only tell you so (node.boundPublicly) — it cannot command them.

Hostnames are a convenience; ports are the substrate. Offline, DNS stops resolving and everything still works at 127.0.0.1:<port>.

HTTPS hostnames

Alzo does not edit /etc/hosts and does not run a DNS resolver. You provision a domain with a wildcard record pointing at loopback, and a local certificate authority issues the certificate:

DNS   *.example.dev  →  127.0.0.1     public, real
Cert  *.example.dev                    local CA, issued once

example.dev in these pages is a placeholder, not a DNS service Alzo provides. Use a domain you control: configure a wildcard A record such as *.dev.your-domain.example pointing to 127.0.0.1. Corporate DNS rebinding protection can block such answers. Then declare an ingress and route ports through it:

import { defineIngress, defineService } from 'alzo';

const local = defineIngress({ hostname: 'dev.your-domain.example', tls: 'internal' });
const api = defineService({
  name: 'api',
  ports: { http: { ingress: local } },
  run: (self) => `node server.js --port ${self.port.http}`,
});

The application must accept that port argument, or read the port from an explicit env callback instead. alzo setup creates and trusts the local certificate authority on macOS, as Installation describes; Linux prints manual trust instructions, and Firefox may need its own trust setup. Run alzo doctor to inspect the configured DNS and trust.

The ingress uses host port 443, and an unrelated listener there must be resolved explicitly. If DNS or certificates are unavailable, use the fallback loopback URLs Alzo prints, remembering that an OAuth callback registered for an HTTPS name will not match a loopback URL. Parallel environments explains the hostname each worktree gets.

Addresses Alzo takes on your machine

Two ranges, both allocated rather than asked for, and both stable per worktree so nothing you write down moves:

ports    20000–29999      one 100-port block per worktree
subnets  172.16.0.0/16    two /24 Docker networks per worktree

172.16.0.0/16 is the one private /16 that Docker's own address pools leave alone, so Alzo never competes with the daemon for an address — and letting the daemon pick is not an option: its pool runs out after about twenty networks, which is ten worktrees. Both ranges are checked before they are claimed: Alzo reads your routing table, your interfaces and Docker's existing networks, and if something already routes a subnet it moves the whole worktree to the next free block and tells you what was in the way. If you are on a VPN that owns 172.16.0.0/16 outright, that is a loud failure naming the interface, never a network that half works.

One name per side of the boundary

A node has two names, and which one you get depends on where you are reading from. Outside the shared Docker network — a host process, your browser, psql in a terminal — you name the published endpoint on example.dev. Inside it, you name the process itself on alzo.internal.

const db = defineService({
  name: 'db',
  provision: { image: 'postgres:16' },
  ports: { pg: { port: 5432 } },
  ready: { tcp: { on: 'pg' } },
});

const api = defineService({
  name: 'api',
  provision: { image: 'acme/api' },
  ports: { http: { port: 8080, ingress: local } },
  dependsOn: [db.available],
  // A container: the inside name, and the container port.
  //   DB_HOST=db.alzo.internal   DB_PORT=5432
  env: () => ({ DB_HOST: db.hostname, DB_PORT: db.port.pg }),
});

const seed = defineService({
  name: 'seed',
  run: 'pnpm tsx watch scripts/seed.ts',
  dependsOn: [db.available],
  // A host process: the outside name, and the allocated port.
  //   DB_HOST=db.example.dev   DB_PORT=20001
  env: () => ({ DB_HOST: db.hostname, DB_PORT: db.port.pg }),
});

The same two lines produce the right address in both places, which is the point — you write the wiring once and Alzo resolves it against whoever is reading. hostname, address and url all move together, so composing hostname and port by hand always agrees with address.

Why two names rather than one: the ingress owns <node>.example.dev inside the network for any node that publishes through it, so something else has to mean "the process". .internal is reserved for private use and can never resolve on the public internet.

A port with ingress is the exception, and it is the whole reason for the split. It is one string from everywhere — https://api.example.dev from a browser, from a host process and from another container — because an OIDC issuer, a CORS origin and a webhook callback are single strings that cross the boundary. Read those through url, never by composing hostname and port.

Injected variables

Addresses are wired explicitly, through env callbacks. Alzo injects only three variables it can name honestly — ALZO_INSTANCE, ALZO_NODE and OTEL_EXPORTER_OTLP_ENDPOINT. There is no ALZO_<NODE>_URL namespace, because your application reads DATABASE_URL or DB_URL or AIRFLOW__DATABASE__SQL_ALCHEMY_CONN; you would write the mapping regardless, and the injected names would go unread.

Mutual references

Two services frequently need each other's addresses: the API needs the web origin for CORS, the web application needs the API URL. This is not a startup cycle — both addresses are known before either process starts — but lexical ordering forbids it.

const web = forward('web', { http: { ingress: local } });

const api = defineService({
  name: 'api',
  ports: { api: { port: 8081, ingress: local } },
  provision: { image: 'acme/api:dev' },
  env: () => ({ CORS_ORIGIN: web.url.http }),
});

defineService({
  name: web,
  run: 'pnpm dev',
  dependsOn: [api.available],
  env: () => ({ VITE_API_URL: api.url.api }),
});

forward hoists a node's address surface — its name and its ports, and nothing else — and the definition completes it by passing the handle as name. Ports are declared once and cannot drift. A forward-declared node trades the compile-time ordering guarantee for a check when the configuration loads; startup dependencies must still be acyclic.

Pinned ports

Ports are allocated, and you do not pick them. The exception is when something outside Alzo already wrote a number down — a Caddyfile, a DSN in a committed .envrc, an OAuth redirect URI registered with a provider, a launch.json debugger attach:

ports: { pg: { port: 5432, hostPort: 5432 } },

Collisions fail loudly rather than reallocating silently, because reallocating defeats the only reason to pin. Since every node is per-instance, pinning states that this node runs in one worktree at a time — true of the things people actually pin — and a second worktree needing the same port gets an error naming both instances.

On this page