Connection Pool authentication fails from edge function

Hello All,
I have already created an issue on the main repo (https://github.com/supabase/supabase/issues/10577) for this, but I thought it might be worth posting here for some wider feedback.

I am attempting to create a pool connection to my supabase DB and keep getting an authentication error.

To reproduce, in an Edge Function:

import { Pool } from "https://deno.land/x/postgres@v0.16.1/pool.ts";

const databaseUrl = (Deno.env.get("SUPABASE_DB_URL") ?? "").replace("localhost", "host.docker.internal").replace('5432', '6543');
const pool = new Pool(databaseUrl, 3, true);
const connection = await pool.connect();


databaseUrl swaps in the correct url (for local development) and the correct port (for on the production server).

However, attempting to connect to the local dev server results in a Connection Refused error (because the port isn't correct) and on production with a PostgresError: SASL authentication failed error.

I can confirm that making a standard connection to the DB using the same password and on the usual port works just fine.

Does anyone know which is the correct port for pool connections on the local dev server? Any idea what might be causing the authentication error?

Many thanks
GitHub
Bug report Connecting to the database from with a pool connection always fails with the error: Uncaught (in promise) PostgresError: SASL authentication failed Connecting to the database with a stra...
Was this page helpful?