I am using typescript + supabase client besides using pg for writing plain sql, the thing is after deploying to production the pg pool connection isn't established correctly returning "Error: connect ECONNREFUSED 44.208..:6543".
I searched multiple times, changed the configurations to connection string and tried to add the certificate but no results at all, still working on localhost and testing server (render) but not on production.
import { config } from 'dotenv';
import { Pool } from 'pg';
config();
const DATABASE = process.env.DATABASE || 'postgres';
const DATABASE_HOST = process.env.DATABASE_HOST || "*********.pooler.supabase.com"
const DATABASE_USER = process.env.DATABASE_USER || "postgres.*********
const DATABASE_PASSWORD = process.env.DATABASE_PASSWORD || "**********"
const options = {
database: DATABASE,
port: 5432,
user: DATABASE_USER,
password: DATABASE_PASSWORD,
host: DATABASE_HOST
};
export const pg = new Pool({
// ...options,
connectionString: `postgres://postgres.ofgasdvffnitvcfycefh:*********@*********.pooler.supabase.com:6543/postgres?pgbouncer=true`
});