On this page

Connection pooling modes

Choose between session mode on port 5432 and transaction mode on port 6543.

#Session mode (5432)

Each client connection gets a dedicated database connection for as long as it stays connected, just like connecting to Postgres directly. Everything works: SET, LISTEN/NOTIFY, temporary tables, advisory locks and prepared statements. Use it for servers, migrations and tools like psql.

#Transaction mode (6543)

Database connections are shared between clients and handed out per transaction. It suits serverless functions and many short-lived connections. Prepared statements sent by drivers are supported. State that lives on a connection between transactions is not: plain SET (use SET LOCAL inside a transaction), LISTEN, SQL-level PREPARE, temporary tables and session advisory locks.

#Choose a port

ToolPort
psql5432
Migrations5432
Long-running server5432 or 6543
Serverless functions6543
LISTEN/NOTIFY5432

#Connection strings

Terminal
# Session mode
postgresql://p_<ref>_owner:<password>@<db-host>:5432/p_<ref>?sslmode=require

# Transaction mode
postgresql://p_<ref>_owner:<password>@<db-host>:6543/p_<ref>?sslmode=require

#Limits

Pooled client connections, pooler database connections and direct database connections are plan limits. See Database limits.