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.
- macOS:
brew install cloudflared - Windows:
winget install --id Cloudflare.cloudflared(or download the .exe from Cloudflare's downloads page) - Linux: install the
cloudflaredpackage from Cloudflare's apt or rpm repository, or download the binary for your architecture
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:54323. 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
- The tunnel runs only while that command is open. Close it when you are done and your database is unreachable again.
- If
localhost:5432is already taken by a local Postgres, point the tunnel at another port, for example--url localhost:6543, and connect there instead. - Each payment keeps your database on. If a plan lapses, logins pause after the grace period and your data is kept until you renew.
Stuck? Email [email protected] and we will help you connect.