Create: failed: pq: duplicate key value violates unique constraint "kms_root_key_scope_id_key"

On FreeBSD: ./boundary dev -database-url=postgresql://postgres:@localhost:5432/boundary works. But after Ctrl-C (as advised here the error below is shown exec the above command again, and Boundary doesn’t start.

Error connecting to database: error creating global scope 
kms keys: create keys: unable to create root key in scope 
global: create root key: root create: create: failed: pq: 
duplicate key value violates unique constraint 

Thank you for trying out Boundary @jhfoo!

It looks like what is happening here is that in dev mode, Boundary creates default keys for root, recovery, and worker auth. If you re-use the DB in dev mode, those tables and values are populated with data already, but when starting up Boundary again, they’ve changed since in dev mode, their values are ephemeral.

You can work around this by constructing a configuration file and passing -config to the dev instance, which will give you the ability keep the keys consistent across restarts.

To make it easy, and because this is a dev server, I would recommend concatenating the example configs for the controller and worker into one config.hcl file.