© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
1 reply
Alex CC

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();
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
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
Connection Refused
error (because the port isn't correct) and on production with a
PostgresError: SASL authentication failed
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
Pool connection to DB fails authentication from edge function · Iss...
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...
Pool connection to DB fails authentication from edge function · Iss...
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Authentication from CRON job -> Edge Function
SupabaseSSupabase / help-and-questions
2mo ago
Edge Function - User authentication from Bearer - how to?
SupabaseSSupabase / help-and-questions
4y ago
PostgreSQL pool connection from express
SupabaseSSupabase / help-and-questions
4y ago
Supabase Edge Functions authentication
SupabaseSSupabase / help-and-questions
2w ago