Running SQL Queries | Docs Firezone Link Search Menu Expand Document

Running SQL Queries


Firezone bundles a Postgresql server and matching psql utility that can be used from the local shell like so:

/opt/firezone/embedded/bin/psql \
  -U firezone \
  -d firezone \
  -h localhost \
  -p 15432 \
  -c "SQL_STATEMENT"

This can be useful for debugging or troubleshooting purposes. It can also be used to modify Firezone configuration data, but this can have unintended consequences. We recommend using the UI (or upcoming API) whenever possible.

Some examples of common tasks:

Listing all users

/opt/firezone/embedded/bin/psql \
  -U firezone \
  -d firezone \
  -h localhost \
  -p 15432 \
  -c "SELECT * FROM users;"

Listing all devices

/opt/firezone/embedded/bin/psql \
  -U firezone \
  -d firezone \
  -h localhost \
  -p 15432 \
  -c "SELECT * FROM devices;"

Changing a user’s role

Set role to 'admin' or 'unprivileged':

/opt/firezone/embedded/bin/psql \
  -U firezone \
  -d firezone \
  -h localhost \
  -p 15432 \
  -c "UPDATE users SET role = 'admin' WHERE email = 'user@example.com';"