Connect to Your PostgreSQL Database

Connection information

To connect your applications to your Bridge PostgreSQL instance, get the connection information by accessing your instance in the dashboard.

  1. Select the database cluster
    Bridge dashboard

  2. View hostname and connection string
    The hostname is always visible. You can also click “Show/Hide Credentials” to toggle displaying the connection string info
    Bridge cluster connection info

You’ll need to provide hostname, username, password, and database name. The default post number is 5432. When your Bridge instance is provisioned, you can log in as the postgres user to create more users and roles. It’s best practice to use postgres only when necessary, so we recommend using another user with only the access permissions they need for your app connection.

Crunchy Bridge requires an SSL connection. Many clients will use SSL by default (but sometimes you may need to include the sslmode=require parameter with the connection code).

Each example below assumes:

  • basic knowledge of the language/framework
  • the specified module or driver is installed before trying out the code samples


Install the psycopg2 package.

You can then use this package to establish a database connection:

import psycopg2

conn = psycopg2.connect("dbname=testdb user=pythonapp password=securepassword")


In a Django app, the database connection parameters are used in The following is an example where the connection info is stored in a .env file:

DATABASE_URL=postgres://djangoapp:[email protected]m:5432/testdb

You could then use a package like dj_database_url to provide the connection data in

import dj_database_url

if os.environ.get('DATABASE_URL'):
    DATABASES['default'] =


Ruby Pg is the Postgres module for Ruby.

require 'pg'

conn = PG.connect(
  dbname: "testdb",
  host: ""
  user: "rubyapp",
  password: "securepassword",
  port: 5432

Ruby on Rails

To use your Bridge instance with a Rails app, you can include the database connection info in database.yml:

  adapter: postgresql
  database: testdb
  username: railsapp
  password: securepassword

Alternatively you can also store the connection info using environment variables.


JDBC is a standard interface for connecting Java to Postgres.

import java.sql.Connection;
import java.sql.DriverManager;

String dbUrl = "jdbc:postgresql://";
Connection conn = DriverManager.getConnection(dbUrl);


Install pg, the Postgres client for Node.js.

const { Client } = require('pg');

const client = new Client({
    user: 'nodeapp',
    host: '',
    database: 'testdb',
    password: 'securepassword',
    port: 5432