Skip to content

Remote database access

A database container is reachable only where its consumers need it. Falak works out the addresses from the sites that reference it; you only decide about public access.

From Address Notes
Containers of the environment on the same server falak-db-<id> on the environment’s Docker network falak-env-<environment> Docker sites join it; Compose stacks start on it
Native sites on the same server 127.0.0.1:<host port> Host ports are allocated from 20000–29999
Sites on other servers of the environment The database server’s private address and the host port Published only on that address, filtered to the consumers’ addresses
Anyone else Nobody Unless you turn on public access

The agent filters published ports in Docker’s DOCKER-USER chain, so Docker’s port publishing never bypasses the firewall.

A site on another server reaches the database over a private network the two servers share. Falak picks the address in this order:

  1. a Falak private network (WireGuard) both servers are members of;
  2. otherwise the provider’s private network, only where both servers are on it for sure: created by Falak with the same provider credential in the same region, on DigitalOcean or Lightsail.

The public IP is never used. Servers that share no private network get a deploy error naming the reason (… shares no private network with <server> …); add both to a network under Network → Private networks (see Private networks) and deploy again.

  1. Reference the database from the site on the other server and save.
  2. The database’s Overview shows Restart required: publish on <address> …. Click Apply: the container is recreated on its volume and publishes the port on the private address.
  3. Deploy the site. Until the address is published, the reference fails with … is not published on <address> yet ….

Off by default. Turn it on under Overview → Limits & settings → Public access to reach the database from outside your servers (a BI tool, a laptop without SSH).

  • The port is published on every address of the server, and TLS is required for every connection (the certificate comes from the Falak CA).
  • Only the networks listed in Allowed sources (IPv4 addresses or CIDRs, such as 203.0.113.9, 198.51.100.0/24) get through Falak’s firewall.
  • Redis and Valkey switch to TLS-only, so their REDIS_URL becomes rediss://.

Use an SSH tunnel to the container’s host port instead of public access:

Terminal window
falak ssh db-1 -- -N -L 5432:127.0.0.1:<host port>
# then connect your client to 127.0.0.1:5432 with the credentials from the panel

The host port is shown in the database’s connection details.