Introduction
Nomatron servers are great at being disposable. They’re stateless, they sit behind a load balancer, and you can replace one without much ceremony. But if the servers hold no state, where does it all go, and what does that ask of you? The answer is PostgreSQL®. Every organization, app, job, environment, operation, role and approval rule lives there.
In this post, you’ll learn exactly what Nomatron needs from PostgreSQL, which settings are worth tuning, how to keep the database private and its secrets out of sight, and how to prove you can restore it before the day you need to.
A quick note on how to read this post. Everything about how Nomatron itself behaves is checked against Nomatron v0.1.7. Anything labeled General PostgreSQL tip is standard database practice that we think is worth following, not a Nomatron-specific requirement or a Nomatron test result. We keep the two apart on purpose.
Why PostgreSQL matters so much to Nomatron
Let’s start with how the pieces fit together, because it explains every recommendation that follows.
- Every Nomatron server in an installation connects to one shared PostgreSQL database and coordinates with the other servers through Serf.
- PostgreSQL is the durable source of truth for Nomatron: organizations, apps, jobs, environments, operations, RBAC and approval configuration.
- The JWT signing secret is persisted in the database too. That’s why the docs describe the database as a trust anchor: its integrity matters for sign-in continuity, configuration trust and recoverability.
- Stored secrets, such as sensitive variables, cluster ACL tokens and OIDC client secrets, are encrypted with
NOMATRON_ENCRYPTION_KEY. That key lives outside the database, and stored secrets can’t be decrypted without it.
Every server shares one database. The encryption key stays outside it.
PostgreSQL is also the only supported backend. If the configured connection string isn’t PostgreSQL, nomatron database init fails.
Which version? Nomatron v0.1.7 is tested with PostgreSQL 16. There’s no enforced minimum, but 16 is the version we test against, so it’s the one to plan around.
Put simply, a healthy, backed-up database plus a safely stored encryption key means your servers are easy to replace. Lose either one and you have a much harder day.
Before you start
You’ll need:
- A plan for a production-style Nomatron v0.1.7 installation.
- An external PostgreSQL service, managed or run by your team. Don’t host a production database inside a Nomatron server allocation or container.
- A secret store for the connection string,
NOMATRON_ENCRYPTION_KEY,NOMATRON_LICENSE_KEY,NOMATRON_CLUSTER_KEYand the root password. - Basic PostgreSQL administration knowledge.
One thing to avoid for anything real: dev mode (nomatron server --dev). It provisions a temporary local PostgreSQL container, which is lovely for a laptop and nowhere else.
Bootstrapping the database
How nomatron database init works
Before the first server start, you run nomatron database init once. It:
- validates configuration the same way
nomatron serverdoes, including licensing and Serf settings; - requires
NOMATRON_ENCRYPTION_KEY; - connects to PostgreSQL and creates the target database if it doesn’t exist yet;
- runs the embedded SQL migrations;
- makes sure the JWT signing key exists;
- seeds permissions and the built-in RBAC roles; and
- creates the root user if no active built-in user exists, and gives it the default super-admin role.
The database name comes from the connection string. It doesn’t have to be called nomatron; that name is used only when the connection string doesn’t name a database.
The user that runs init must be able to connect and, unless the database already exists, create it. If you’d rather not hand out that privilege, create the database ahead of time with your normal provisioning workflow.
Running init with secrets from files
Load the keys from your secret store into the environment, then point init at files for the connection string and root password:
export NOMATRON_LICENSE_KEY="$(cat /run/secrets/nomatron_license_key)"
export NOMATRON_CLUSTER_KEY="$(cat /run/secrets/nomatron_cluster_key)"
export NOMATRON_ENCRYPTION_KEY="$(cat /run/secrets/nomatron_encryption_key)"
nomatron database init \
--config /etc/nomatron/nomatron.hcl \
--database-url-file /run/secrets/nomatron_db_url \
--root-password-file /run/secrets/nomatron_root_passwordNothing secret appears on the command line or in your shell history. If the root password isn’t supplied, init creates root with a well-known default password, so always set it here. If you prefer pipes, --database-url-stdin and --root-password-stdin do the same job.
What you should see
Init finishes without errors, and the first nomatron server start comes up healthy. If it fails, the error messages are refreshingly specific: a missing license key, cluster key or encryption key each has its own message, and a database user without create rights fails at the database creation step.
Treat init as a bootstrap step, not something to run on every restart. The server itself also connects to PostgreSQL and runs migrations every time it starts.
That’s safe with more than one server. Migrations are serialized with a database lock, so if several servers start at once after an upgrade, one runs the migrations while the others wait their turn. There’s no required rollout order.
Checkpoint: the database exists, migrations have run, and root has a password you chose.
Setting the connection string
The server reads its connection string from database.connection_string or the NOMATRON_DB_URL environment variable. To override it at start-up from a file or stdin, use --db-url-file or --db-url-stdin.
Keep the full connection string, with its password, in your secret store, and never in source control or rendered config. The file your secret store renders contains a single line in this shape, with the password filled in only at render time:
postgres://nomatron:<DB_PASSWORD>@db.example.internal:5432/nomatron?sslmode=requireThen start the server with the connection string read from that file:
export NOMATRON_DB_URL="$(cat /run/secrets/nomatron_db_url)"
nomatron server --config /etc/nomatron/nomatron.hclHere’s why setting it matters: the built-in default is a local connection string with sslmode=disable, meant for development only. Always set your own outside local development. If you deploy with the Nomatron Nomad Pack, it reads the connection string from the db_url key in a Nomad Variable, which keeps it out of the job file entirely.
The connection string accepts the standard libpq TLS parameters, so you aren’t limited to sslmode=require. Set sslmode=verify-full and sslrootcert to check the server’s certificate against your CA, and add sslcert and sslkey if your database expects client certificates.
Tuning the connection pool
Each Nomatron server keeps its own pool of database connections. These four settings in the database block control it:
| Setting | Environment variable | Default when unset |
|---|---|---|
max_open_conns | NOMATRON_DB_MAX_OPEN_CONNS | 50 |
max_idle_conns | NOMATRON_DB_MAX_IDLE_CONNS | 25 |
conn_max_lifetime_seconds | NOMATRON_DB_CONN_MAX_LIFETIME_SECONDS | 1800 (30 minutes) |
conn_max_idle_time_seconds | NOMATRON_DB_CONN_MAX_IDLE_TIME_SECONDS | 300 (5 minutes) |
Those defaults add up quickly once you run several servers. We recommend starting from the values in the configuration file example in the docs instead:
database {
# The connection string comes from NOMATRON_DB_URL, read from your secret store.
max_open_conns = 25
max_idle_conns = 10
conn_max_lifetime_seconds = 1800
conn_max_idle_time_seconds = 300
}max_open_conns caps how many connections one server opens, and the docs say to tune it with your database capacity. The two lifetime settings recycle connections, which the docs call useful behind proxies or managed databases. Treat these values as a starting point, and adjust them once you’ve seen your real connection counts.
The rule of thumb that matters most: the number of Nomatron servers multiplied by max_open_conns must stay below PostgreSQL’s max_connections, with headroom for every other client that connects.
Servers times max_open_conns has to fit under max_connections, with headroom.
General PostgreSQL tip: when you work out that headroom, count admin sessions, backups, monitoring and replication. Three servers at 25 each is 75 before anyone else connects. If a proxy or load balancer sits between Nomatron and PostgreSQL, keep conn_max_lifetime_seconds below its idle timeout so connections are recycled before they’re cut.
If you’re thinking about a connection pooler, one thing to avoid: don’t put PgBouncer in transaction-pooling mode in front of Nomatron. Nomatron uses session advisory locks and LISTEN/NOTIFY, and both need a connection that stays with one session. We haven’t tested session pooling or cloud database proxies, so if you use either, validate it in staging first.
Sizing
The Nomatron docs size the servers, not the database:
| Environment | Nomatron servers | Per-server CPU | Per-server memory |
|---|---|---|---|
| Evaluation | 1 | 2 vCPU | 4 GB |
| Production starting point | 3 | 2–4 vCPU | 4–8 GB |
Both shapes use one external PostgreSQL service, sized and monitored separately. The docs describe these as intentionally conservative starting points, not benchmarks. They also make a point worth repeating: scaling the application tier without watching the database tier just moves the bottleneck. Scale server count and database capacity together.
We don’t publish starting sizes for the database itself. What makes it grow over time is audit logs (their retention is configurable), operation and plan history, and stored GitHub webhook payloads, so those are the numbers to watch.
General PostgreSQL tip: start modestly on a managed instance, then let observation drive sizing. Watch CPU, memory, connection count, storage growth and slow queries for a few weeks, and resize from what you see rather than from a guess.
Securing the database
From the Nomatron production hardening and best practices guides:
- Keep PostgreSQL on private networking, in private subnets or inside a managed service boundary.
- Allow inbound database traffic only from Nomatron servers and approved admin paths. Never open
0.0.0.0/0to PostgreSQL. - Keep platform operators, database operators and security administrators in separate roles.
- Protect the database as a trust anchor: guard against casual administrator sprawl, unaudited manual changes, weak backup handling and silent schema drift.
- Use TLS on the connection. The docs’ examples use
sslmode=require, and the troubleshooting guide listssslmodeand TLS expectations as a common cause of connection failures.
General PostgreSQL tip: go one step further where your service supports it. Verify the server’s certificate against your CA rather than only requiring encryption, connect with a dedicated login role rather than a superuser, rotate the database password through your secret store, and pre-create the database so the runtime role doesn’t need permission to create databases.
One Nomatron-specific limit on least privilege: the server runs migrations every time it starts, so the role it connects as needs schema-change (DDL) rights on the Nomatron database. In v0.1.7 there’s no supported way to split those rights into a separate migration role.
Planning for failure
The production hardening guide is clear that resilience doesn’t stop at the application tier. It recommends managed highly available PostgreSQL where it’s available, or a clearly operated design if you run PostgreSQL yourself, along with tested backup retention, restore drills and monitoring of replication or failover health where relevant.
It’s also worth knowing what failure looks like from Nomatron’s side. A PostgreSQL restart or failover can make /api/v1/health fail, and so can connection exhaustion. Because the health endpoint includes database readiness, your load balancer sees the problem too.
General PostgreSQL tip: point the connection string at a stable writer endpoint provided by your database service, not at an individual node. The example connection string in the Nomad Pack guide does exactly this, with a writer hostname.
The good news is that you don’t need to restart anything afterwards. Nomatron servers reconnect on their own, and dead connections are replaced on the next query. While the database is unavailable, /api/v1/health returns a 503 with database unavailable, which is exactly what your load balancer and alerting should see.
Backing up and testing restores
What to back up
The Nomatron backup and recovery guide lists:
- the Nomatron PostgreSQL database;
- the Nomatron server configuration;
NOMATRON_ENCRYPTION_KEY, backed up separately from the database (it can’t be rotated from the CLI in v0.1.7);NOMATRON_LICENSE_KEYandNOMATRON_CLUSTER_KEY;- the Serf gossip key (
serf.encrypt_key) for multi-server installations; and - the deployment manifests you use to run Nomatron.
That second-to-last group is easy to forget. A perfect database backup is no use if the encryption key that unlocks its secrets went down with the old server.
For the database itself, decide and write down your backup frequency, retention period, storage location, access permissions, restore test process, and who owns recovery during an incident.
Running a restore test
The docs are blunt about it: don’t treat backup as complete until a restore has been tested. A basic restore test looks like this:
- Restore the backup into a clean PostgreSQL instance.
- Start Nomatron against the restored database.
- Check that organizations, apps, jobs, environments and operations are visible.
- Check that RBAC and approval configuration are present.
- Confirm whether any tokens or secrets need to be re-issued.
If all five pass, you have a recovery plan rather than a backup habit.
It also helps to remember what an outage means in practice. If Nomatron is unavailable, existing Nomad workloads keep running in Nomad. New Nomatron-managed deployment workflows may pause, so agree your fallback path before you need it.
Take a backup before every upgrade, too. Nomatron’s schema migrations only go forward, so if an upgrade goes wrong, the way back is to restore the pre-upgrade backup and run the matching Nomatron version.
Back up and test a restore, upgrade forward, and roll back by restoring.
General PostgreSQL tip: combine point-in-time recovery (WAL archiving, or your managed service’s point-in-time restore) with regular logical dumps for portability. Encrypt backups, keep them in a separate account or location, and guard them as carefully as the live database.
Separating environments
The best practices guide recommends separate Nomatron deployments for development, staging and production, each with its own PostgreSQL database, secrets and hostname. Never reuse production secrets in a lower environment.
Test Nomatron upgrades in staging first: validate startup, health and the main user flows, and confirm the database path behaves as expected before you move on to production.
Monitoring and troubleshooting
From the Nomatron side, watch:
- PostgreSQL availability and connection behavior;
/api/v1/healthon every server;- database bootstrap status at
GET /api/v1/database/status; and - backup success and failure.
When something goes wrong, the troubleshooting guide sorts database problems into three shapes:
- The server can’t connect. Check the hostname and port, the username and password,
sslmodeand TLS expectations, firewalls and private-network reachability, and whether PostgreSQL is ready to accept connections. - Startup reaches the database, then fails. That usually points to migrations, init not having been run, missing database permissions, or a database that’s reachable but not usable by the configured account.
- Health drops later. Look at firewall or load balancer changes, PostgreSQL restart or failover, certificate rotation, or connection exhaustion.
General PostgreSQL tip: on the database side, track active connections against max_connections, replication lag, autovacuum activity and table bloat, slow queries (for example with the pg_stat_statements extension), and disk growth. Most database surprises announce themselves in one of those graphs first.
Putting it all together: a production checklist
Before you call your Nomatron database production-ready, check that you have:
- an external, private PostgreSQL service;
- TLS on the connection;
- the connection string and keys in a secret store, read from files or the environment;
nomatron database initrun once, with a root password you chose;- pool sizes budgeted against
max_connections; - a highly available setup or a written recovery plan;
NOMATRON_ENCRYPTION_KEYbacked up separately from the database;- a backup taken before every upgrade; and
- a restore you’ve actually tested.
Summary
In this post, we looked at why PostgreSQL is the heart of a Nomatron installation: it holds all the state, including the JWT signing secret, while the encryption key that protects stored secrets lives outside it. We bootstrapped the database once with secrets read from files, set the connection string and pool safely, and worked through security, failure planning, backups and restore tests.
If you’re planning a production Nomatron installation, this is a good fit for your first design review with your database team. For every setting, see the database initialization, configuration file and backup and recovery docs.
Want to run Nomatron against your own PostgreSQL? Get early access.
PostgreSQL is a registered trademark of the PostgreSQL Community Association of Canada. HashiCorp and Nomad are trademarks of HashiCorp. Nomatron is not affiliated with or endorsed by the PostgreSQL Community Association of Canada, the PostgreSQL Global Development Group or HashiCorp. Other names may be trademarks of their respective owners.






