Connect to your database

Your database is not open to the public internet. You reach it through a short-lived encrypted tunnel that you start on your own machine. Nothing is exposed until you run the command, and the connection is TLS the whole way.

1. Install cloudflared

This is Cloudflare's free command-line tool. Install it once.

2. Open the tunnel

Run this and leave it running. It listens on your own machine at localhost:5432 and forwards traffic to your database. The first time, it opens a browser to confirm it is you.

cloudflared access tcp --hostname pg.cognabase.com --url localhost:5432

3. Connect with your credentials

Open a second terminal. Your database name, user and password are shown once in your dashboard when you create the database (reset the password there any time). Put them in place of USER, PASSWORD and DBNAME.

psql "postgresql://USER:PASSWORD@localhost:5432/DBNAME?sslmode=require"

Keep sslmode=require so the connection stays encrypted. Any Postgres client works the same way: point Prisma, Django, Rails, TablePlus, DBeaver or your own code at localhost:5432 while the tunnel is running.

Notes

Stuck? Email [email protected] and we will help you connect.

Connect to your database | Cognabase