Skip to content
NordBaseDocs

Search the docs

Find a page or a section of the NordBase docs

Connect

Connection URL

The one string your app needs: its parts, the Endpoints and ports, the optional variables and how the libraries choose a Region.

Software reaches a Database through one environment variable, NORDBASE_URL. It holds the Connection URL: a Credential and an Endpoint, written as a standard URL. Any existing driver, ORM or GUI accepts it unchanged, including psql, mongosh, Prisma, Drizzle and Rowan.

In the examples on this page, <base> stands for the NordBase domain, which is not final yet. The console always shows the full value to copy.

Identifiers and secrets

ThingFormatExample
Database iddb- and 10 lowercase letters or digitsdb-k7q2x9m4p1
Credential id (the username)cr_ and 10 lowercase letters or digitscr_4k2m8p0d9a
Credential secret (the password)nbs_ and 40 letters or digitsnbs_…
Region code<country>-<city>, lowercasefi-hel, de-fsn

The Database id uses a hyphen because it is also the first label of every Endpoint, so it has to be valid in a DNS name.

Secrets have a fixed prefix so secret scanners can find a leaked one. The NordBase libraries never log a secret or a full Connection URL. Where they show the URL, the secret reads nbs_****.

SQL Connection URL

postgresql://cr_4k2m8p0d9a:nbs_…@db-k7q2x9m4p1.fi-hel.nordbase.<base>:5432/db-k7q2x9m4p1?sslmode=verify-full&sslrootcert=system
PartExampleWhat it is
Usernamecr_4k2m8p0d9aThe Credential id
Passwordnbs_…The Credential secret
Endpointdb-k7q2x9m4p1.fi-hel.nordbase.<base>The Database in one Region
Port5432Routed port. Use 5433 for the Direct port
Path/db-k7q2x9m4p1The Database id. The Router finds your Database by it, so TLS SNI is not required
sslmode=verify-full&sslrootcert=systemTLS with the certificate and the name checked against the system's certificates (libpq 16+)

There is one PostgreSQL database per NordBase Database. Inside it you work in schema public and in any schemas you create.

Document Connection URL

mongodb://cr_4k2m8p0d9a:nbs_…@db-k7q2x9m4p1.fi-hel.nordbase.<base>:27017/?tls=true&authMechanism=SCRAM-SHA-256

The Endpoint finds your Database by the TLS server name (SNI), which every official MongoDB driver sends. You choose a Namespace in code, for example client.db('app'). See Document Databases.

Endpoints and ports

A Database has one Endpoint in every Region where it has an Instance:

<database-id>.<region>.nordbase.<base>

A Database with its Primary in Helsinki and a Replica in Falkenstein has two Endpoints:

db-k7q2x9m4p1.fi-hel.nordbase.<base>
db-k7q2x9m4p1.de-fsn.nordbase.<base>
PortEngineWhat it is
5432SQLRouted. Transaction pooling. Reads go to the nearest healthy Instance, Writes to the Primary. Any Region's Endpoint takes Writes and forwards them to the Primary
5433SQLDirect. Session pooling, always the Primary. For migrations, LISTEN/NOTIFY, session SET, advisory locks and temporary tables
27017DocumentMongoDB wire protocol. Reads and Writes go to the Primary for now

To use the Direct port, change 5432 to 5433 in the URL and keep everything else. See Replicas and Consistency for how routing and pooling behave.

Optional variables

NORDBASE_URL is the only variable you need. Every NordBase library also honours two optional ones:

VariableWhat it does
NORDBASE_REGIONThe Region code to serve Reads from, such as de-fsn. If the Database has no Instance there, the library ignores it and prints a warning
NORDBASE_KEY_FILEPath to a key file. Used when NORDBASE_URL is not set

Key file

When you create a Credential you can download a key file once, the same way you would download a service account key. It holds everything a library needs:

json
{
  "type": "nordbase_credential",
  "version": 1,
  "database_id": "db-k7q2x9m4p1",
  "engine": "sql",
  "credential_id": "cr_4k2m8p0d9a",
  "secret": "nbs_…",
  "home_region": "fi-hel",
  "endpoints": {
    "fi-hel": "db-k7q2x9m4p1.fi-hel.nordbase.<base>",
    "de-fsn": "db-k7q2x9m4p1.de-fsn.nordbase.<base>"
  },
  "connection_url": "postgresql://…"
}
bash
export NORDBASE_KEY_FILE=/etc/shop/nordbase-key.json

The key file contains the secret. Keep it out of your repository and readable only by the process that needs it. If NORDBASE_URL is also set, the URL wins.

Region discovery

A DNS TXT record lists a Database's Regions, so a library needs no API call and no Access token to find them:

_nordbase.db-k7q2x9m4p1.nordbase.<base>  TXT  "v=1; engine=sql; home=fi-hel; regions=fi-hel,de-fsn"

You can read it yourself:

bash
dig +short TXT _nordbase.db-k7q2x9m4p1.nordbase.<base>

How the libraries choose a Region

On first use, once per process, a library picks the Region to serve Reads from:

  1. If NORDBASE_REGION is set and the TXT record lists that Region, it uses it.
  2. Otherwise, if the record lists one Region, it uses that one.
  3. Otherwise it opens a TCP connection to port 5432 (27017 for Document Databases) of every listed Endpoint at the same time, with a 1.5 second timeout, and picks the fastest. If none answers in time, it uses the Endpoint in the URL.

The choice only changes where Reads are served. Writes always reach the Primary, and correctness never depends on which Region was picked.

With another driver or ORM, put the Endpoint of the nearest Region in the URL yourself. The Credential and path stay the same.

TLS

Every Endpoint uses a publicly trusted certificate from Let's Encrypt, so your system's root certificates are enough. There is no certificate to download.

  • SQL URLs carry sslmode=verify-full: the connection is encrypted and the certificate and name are checked.
  • Document URLs carry tls=true.
  • psql and other tools built on libpq look for a root certificate file in your home folder by default. Add sslrootcert=system (libpq 16 or newer) so they use the system's certificates instead.

Coming later

  • An HTTP query endpoint for runtimes that cannot open TCP connections.
  • A global Endpoint, <database-id>.nordbase.<base>, that resolves to the nearest Region.