Skip to main content
The database connection page contains the host, port, username, database name, and connection string for your PostgreSQL instance.

Connection string

A PostgreSQL connection string usually looks like this:
postgresql://<user>:<password>@<host>:5432/<database>?sslmode=require
Set it as an environment variable in your application:
export DATABASE_URL="postgresql://<user>:<password>@<host>:5432/<database>?sslmode=require"

Test with psql

psql "$DATABASE_URL"
Run a simple query:
select version();

TLS

Use TLS for application connections. If your framework supports sslmode=require, keep it enabled in production.
postgresql://<user>:<password>@<host>:5432/<database>?sslmode=require

Application examples

import pg from "pg";

const pool = new pg.Pool({
  connectionString: process.env.DATABASE_URL,
  ssl: { rejectUnauthorized: false }
});
Treat database passwords like secrets. Do not commit connection strings to Git.