© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•7d ago
Max Braun

Connection times out in Transaction mode only

🔢DB Connections
I'm switching our Drizzle connection driver from node-postgres to postgres-js because our app runs in a serverless environment. The same connection string that worked before now times out.

The main issue is that I can (using the exact connection code that Supabase instructs for connecting with Drizzle) connect fine to my database if I use the 5432 port (Sessions mode), but the second I change that port to 6543, the connection times out. This exact setup with the correct 6543 port worked just fine with node-postgres.

Additional context:
- We have the paid IPv4 addon enabled
- We use the dedicated pooler

Here's my connection logic:

import { PRIVATE_DATABASE_CERT } from '$env/static/private';
import postgres from 'postgres';
import { drizzle } from 'drizzle-orm/postgres-js';
import * as schema from './schema';
import * as relations from './relations';

const client = postgres(`postgres://<DB_USERNAME>:${encodeURIComponent("<DB_PASSWORD>")}@db.<PROJECT_ID>.supabase.co:6543/postgres`, {
  prepare: false,
  ssl: {
    ca: PRIVATE_DATABASE_CERT,
  },
  max: 1,
  idle_timeout: 20,
  max_lifetime: 60 * 30,
});

const db = drizzle({
  client,
  schema: { ...schema, ...relations },
});

export default db;
import { PRIVATE_DATABASE_CERT } from '$env/static/private';
import postgres from 'postgres';
import { drizzle } from 'drizzle-orm/postgres-js';
import * as schema from './schema';
import * as relations from './relations';

const client = postgres(`postgres://<DB_USERNAME>:${encodeURIComponent("<DB_PASSWORD>")}@db.<PROJECT_ID>.supabase.co:6543/postgres`, {
  prepare: false,
  ssl: {
    ca: PRIVATE_DATABASE_CERT,
  },
  max: 1,
  idle_timeout: 20,
  max_lifetime: 60 * 30,
});

const db = drizzle({
  client,
  schema: { ...schema, ...relations },
});

export default db;


Please help!
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Read-only transaction error
SupabaseSSupabase / help-and-questions
4y ago
psql connection times outI
SupabaseSSupabase / help-and-questions
4y ago
Connection type: Direct or Transaction pooler
SupabaseSSupabase / help-and-questions
7mo ago
cannot execute DELETE in a read-only transaction
SupabaseSSupabase / help-and-questions
4y ago