Setup EdgeDB for single-server deployment

Today, many people talk about microservice. The new-born EdgeDB also doesn't stay outside that trend. But not every website is applicable for microservice. Due to low traffic, low budget, some websites still prefer single-server deployment, meaning that everything, application and databases, are hosted in the same server. But EdgeDB lacks a traightforward documentation for this setup. This post is to guide how to do.

Install EdgeDB package

Follow this guide to install EdgeDB package on your server, but hold on before "Enable a systemd unit​" section.

Setup simple authentication for EdgeDB

In single-server deployment, the database systems don't serve applications outside that server. We can configure to:

  • EdgeDB server only listens on localhost (
  • Not require password for connection from same-server apps.

In PostgreSQL, password-less authentication can be achieved by using peer authentication. But in EdgeDB, I haven't found that mode yet, so we will use "trust" method.

Create a file /etc/systemd/system/edgedb-server-4.service.d/override.conf with this content:

ExecStart=/usr/lib/x86_64-linux-gnu/edgedb-server-4/bin/edgedb-server --data-dir=${EDGEDATA} --runstate-dir=%t/edgedb --tls-cert-mode=generate_self_signed --default-auth-method=trust --binary-endpoint-security=optional

Then start the EdgeDB server by:

$ sudo systemctl start edgedb-server-4

At the first time we run this, it will take a while, for EdgeDB to generate self-signed TLS certificate.

After this, we can make EdgeDB server auto-start:

$ sudo systemctl enable edgedb-server-4

Create database

Assume that our application wants the database to be named our-db-name, we create it by:

$ edgedb --port 5656 --tls-security insecure database create our-db-name

Create instance linking with created database

For convenience, we should define an EdgeDB instance:

$ edgedb instance link --trust-tls-cert OurWeb

When this command asks for database name, give it the value in the previous step.

From now on, we can connect to our EdgeDB database, from CLI or from our app, with this instance name.

$ edgedb -I OurWeb restore