# Connect an app to a database or app > Read the connection details of a database or another Orchard app through a variable that stays current. Source: https://docs.orchard.hackclub.com/deploy/connect-resources/ Connect an app to a database or to another app in the same project, and the app reads the connection details from a [variable](/run/environments/). 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: ```txt ${{resource..}} ``` ## Prerequisites - Edit access to the project. - A database or app in the same project. ## Connect a resource **Dashboard** 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 `_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**. **CLI** To connect a database and add `DATABASE_URL`, run the following command: ```sh orchard deploy bindings add --database ``` To connect an app, run the following command: ```sh orchard deploy bindings add --app ``` | Flag | Description | | ---------- | ------------------------------------------------------------------------------------ | | `--as` | The connection name used in the reference. The default comes from the resource name. | | `--env` | The variable to add. | | `--no-env` | Connect the resource without adding a variable. | To list the resources that you can connect, run the following command: ```sh orchard deploy bindings options ``` ## Available fields | Resource | Field | Value | | -------- | ------------------- | ------------------------------------------------------------------ | | Database | `connection_string` | The full Postgres connection string. This value is secret. | | Database | `host` | The database host. | | Database | `port` | The database port. | | Database | `database` | The database name. | | Database | `user` | The database user. | | Database | `password` | The database password. This value is secret. | | App | `url` | The internal URL of the app, in the format `http://:`. | | App | `host` | The internal hostname of the app. | | App | `port` | The port of the app's first service. | App fields come from the app's first service. An app with no service has no fields. ## Limits - 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. ## Remove a connection **Dashboard** 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. **CLI** Remove all variables that use the connection, then run the following command: ```sh orchard deploy bindings remove ``` You cannot delete a database while an app is connected to it. ## Unresolved references 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. ## Related resources - [Create and manage a database](/data/databases/) - Create the Postgres database an app connects to. - [score.yaml](/deploy/score/) - Declare database connections in a file in the repository. - [`orchard deploy bindings` reference](/reference/cli/#deploy) - Every flag of the `orchard deploy bindings` commands.