Connecting directly to Postgres (psql, pg_dump, ORMs)

How to connect psql, pg_dump, Prisma, Drizzle or a GUI straight to a SupaHost project's Postgres over the SSH tunnel on Business, and what to use on other plans.

Direct Postgres connections on SupaHost go through an SSH tunnel and are available on the Business and Enterprise plans. Postgres isn't exposed to the internet on any plan: port 5432 listens only inside the instance. On Builder and Pro, use the Data API, Studio's SQL editor, the MCP server or the exports instead.

On Business and Enterprise

1. Add your SSH key

Go to Dashboard → your project → Connect → SSH & CLI, paste your public key (for example the contents of ~/.ssh/id_ed25519.pub) and click Add key. It works within a minute. Only the instance owner can add keys; you can have up to 20.

2. Open the tunnel

Leave this running in a terminal:

ssh -N -L 5432:127.0.0.1:5432 [email protected]

If you already run Postgres locally on 5432, forward a different local port:

ssh -N -L 6543:127.0.0.1:5432 [email protected]

3. Get the connection string

On Connect → Database, click Show connection string:

postgresql://postgres:<password>@127.0.0.1:5432/p_app_one

The database name is p_ plus your project name with - replaced by _. Change the port if you forwarded a different one.

4. Connect your tool

psql "postgresql://postgres:<password>@127.0.0.1:5432/p_app_one"

pg_dump -Fc -f app-one.dump "postgresql://postgres:<password>@127.0.0.1:5432/p_app_one"

For Prisma or Drizzle, set the same URL as DATABASE_URL in your local .env. There's no connection pooler on SupaHost, so there's no separate "pooled" URL or pgbouncer=true flag: use the one URL for both queries and migrations.

Quick SQL without a tunnel

Over plain SSH, you can open psql for a project, or run one statement:

ssh [email protected]
sudo supahost-psql app-one
sudo supahost-psql app-one -c "select count(*) from public.bookings"

On Builder and Pro

Task Use
Run SQL by hand Studio's SQL editor (Database tab → Open Studio)
Query from your app supabase-js and the Data API
Let an AI agent run SQL or migrations The MCP server's execute_sql and apply_migration
Take a database dump Create pg_dump on the Backups tab
Use Prisma or Drizzle against SupaHost Needs a direct connection, so Business or Enterprise. See Prisma and Drizzle ORM

Things to know

  • The tunnel is for your tools, not production traffic. Serverless and edge platforms can't hold an SSH tunnel open. Have those apps use the Data API or Edge Functions.
  • Connections are shared. One Postgres server serves every project on the instance, with max_connections = 400 in total. Keep ORM pool sizes small, especially in development servers that reload often.
  • You sign in as postgres, the same role you'd use on Supabase Cloud. It can create objects in public and is subject to normal permissions.
  • Only the tunnel works. 127.0.0.1:5432 in the connection string means "through your local end of the tunnel". The string won't work without it.
  • SSH access is restricted: you can't get a root shell, and the instance's cloud credentials are blocked.

Updated 11 November 2026 · View as Markdown · Something wrong or missing? Tell us