Skip to content
Install

Connect an app to a database or app

Connect an app to a database or to another app in the same project, and the app reads the connection details from a variable. Orchard stores a reference instead of a copied value, so the variable stays correct after a password rotation or a restore, and you never paste a password by hand.

A reference has this format:

${{resource.<connection>.<field>}}
  • Edit access to the project.
  • A database or app in the same project.
  1. Open the app.
  2. Go to Variables.
  3. Select Use a resource.
  4. Select a database or app.
  5. Select Save.

For a database, Orchard adds the variable DATABASE_URL if the name is free. For an app, Orchard adds a variable named <NAME>_URL.

To read a different field, select the reference in the variable row, then select the field. To replace the reference with text, select Type a value instead.

ResourceFieldValue
Databaseconnection_stringThe full Postgres connection string. This value is secret.
DatabasehostThe database host.
DatabaseportThe database port.
DatabasedatabaseThe database name.
DatabaseuserThe database user.
DatabasepasswordThe database password. This value is secret.
AppurlThe internal URL of the app, in the format http://<host>:<port>.
ApphostThe internal hostname of the app.
AppportThe port of the app’s first service.

App fields come from the app’s first service. An app with no service has no fields.

  • An app can connect to 20 resources.
  • A connection name starts with a lowercase letter. It contains only lowercase letters, digits, and underscores. It has 32 characters at most.
  1. Open the app.
  2. Go to Variables.
  3. Remove all variables that use the connection.
  4. Select Save.

Orchard removes a connection when no variable uses it.

You cannot delete a database while an app is connected to it.

If a variable refers to a connection or field that does not exist, the app does not start. Orchard does not pass an empty value to the app.