Configuration

Database

Configuration for database connections.
Environment Variables
Environment variables are configurable for Directus Enterprise Cloud projects via our Customer Success team. You can also set environment variables in self-hosted projects.
VariableDescriptionDefault Value
DB_CLIENTRequired. What database client to use. One of pg or postgres, mysql, oracledb, mssql, sqlite3, cockroachdb.
DB_HOSTDatabase host. Required when using pg, mysql, oracledb, or mssql.
DB_PORTDatabase port. Required when using pg, mysql, oracledb, or mssql.
DB_DATABASEDatabase name. Required when using pg, mysql, oracledb, or mssql.
DB_USERDatabase user. Required when using pg, mysql, oracledb, or mssql.
DB_PASSWORDDatabase user's password. Required when using pg, mysql, oracledb, or mssql.
DB_FILENAMEWhere to read/write the SQLite database. Required when using sqlite3.
DB_CONNECTION_STRINGWhen using pg, you can submit a connection string instead of individual properties. Using this will ignore any of the other connection settings.
DB_EXCLUDE_TABLESCSV of tables you want Directus to ignore completelyspatial_ref_sys,sysdiagrams
DB_CHARSET / DB_CHARSET_NUMBERCharset/collation to use in the connection to MySQL/MariaDBUTF8_GENERAL_CI
DB_VERSIONDatabase version, in case you use the PostgreSQL adapter to connect a non-standard database. Not usually required.
DB_HEALTHCHECK_THRESHOLDHealthcheck timeout threshold in milliseconds.150

Additional Database Variables

All DB_* environment variables are passed to the connection configuration of a Knex instance. This means you can extend the DB_* environment variables with any values you need to pass to the database instance.

This includes:

  • DB_POOL__ prefixed options which are passed to tarn.js.
  • DB_SSL__ prefixed options which are passed to the respective database driver. For example, DB_SSL__CA which can be used to specify a custom Certificate Authority (CA) certificate for SSL connections. This is required if the database server CA is not part of Node.js' trust store.