When you're using knex
with a Postgres database, the DATABASE_URL
environment variable is typically a connection string that includes the username, password, host, port, and database name.
postgres://username:password@localhost:5432/mydatabase
In the knex
configuration, you can simply provide this DATABASE_URL
as the connection. Knex can parse connection strings directly:
knex({
client: 'pg',
connection: process.env.DATABASE_URL,
});
In the context of fly.io
, you'd generally obtain your DATABASE_URL
as an environment variable set within your Fly.io application configuration.