pgquery

pgquery / Connect to Supabase

Guide · Connect

Connect pgquery to Supabase

Supabase databases are regular PostgreSQL. You need one connection string from the dashboard; the only trick is choosing the right one.

1. Copy the connection string

  1. Open your project at supabase.com/dashboard.
  2. Click Connect at the top of the page.
  3. Under Connection string, choose Session pooler.
  4. Copy the URI and replace [YOUR-PASSWORD] with your database password (Project Settings → Database if you need to reset it).

It looks like this:

postgresql://postgres.abcdefghijkl:YOUR-PASSWORD@aws-0-eu-central-1.pooler.supabase.com:5432/postgres?sslmode=require

2. Paste it into pgquery

Open the app, paste the string into the connection form and press Connect. Your tables are under the public schema; Supabase's own schemas (auth, storage) are listed too.

Which string to use

  • Session pooler, port 5432: use this one. It works over IPv4 and supports everything pgquery does.
  • Direct connection (db.<ref>.supabase.co): IPv6 only unless you bought the IPv4 add-on, so it often fails from Docker and many servers.
  • Transaction pooler, port 6543: avoid. It doesn't keep prepared statements between queries, which pgquery uses.

Common errors

If you seeDo this
dial tcp [2a05:…]:5432: connect: network is unreachableYou used the direct connection, which is IPv6-only. Switch to the session pooler string.
prepared statement "stmtcache_…" already exists (SQLSTATE 42P05)You used the transaction pooler (port 6543). Use the session pooler on port 5432.
password authentication failed for user "postgres"Check the password, and that the user is postgres.<your-project-ref> for the pooler.
Tenant or user not foundThe project ref in the user name or the region in the host is wrong. Copy the string again from Connect.

Good practice

For day-to-day browsing, create a role with only the rights you need instead of using postgres. Remember that the postgres role bypasses Row Level Security, so what you see is not what your app's users see. Test policies with SET ROLE authenticated; in the SQL editor.

Questions

Does pgquery work with Supabase?

Yes. Supabase databases are standard PostgreSQL; connect with the session pooler connection string.

Why does the direct connection fail?

Supabase direct connections use IPv6 unless you add the IPv4 add-on. The session pooler works over IPv4.

More chapters