The runway service dsn <name>
command generates a Data Source Name (DSN) for your service and sets it as an environment variable, making it immediately available for automation and seamless integration with your applications.
DSNs are supported by a number of frameworks and represent the credential string that is necessary for your application to connect to e.g. a database. We support PostgreSQL (DATABASE_URL
) and Cache (REDIS_URL
).
$ runway service dsn db-test
DATABASE_URL=postgres://app:xxx@db-test-rw.db-test.svc.cluster.local:5432/app
The following example shows how to assign the DSN to your application:
$ runway app create -a my-new-app
...
$ runway service create new-db --type postgres --plan std-launch
...
$ runway app config set $(runway service dsn new-db) -a my-new-app
...
A DSN is a formatted connection string that provides all the necessary details for an application to connect to a database or service. It typically includes information such as the username, password, host, port, database name, and sometimes additional connection options. For example, a DSN for PostgreSQL might look like this:
postgres://username:password@hostname:port/database?sslmode=require
By using this the runway service dsn
command, Runway eliminates the need to manually configure or retrieve connection details. The DSN is automatically prepared and injected into your app’s environment via (runway app config set
), ensuring that your services are ready to use the database with minimal setup.
This approach simplifies workflows, supports automation, and ensures consistency across deployments.