Supabase connection guide

Supabase PostgreSQL Connection String

Find the right Supabase Postgres URI for a desktop client, application runtime, or migration command, including direct and pooled connections.

Use the connection value generated by Supabase, keep it in an environment variable, and test it before changing application code. The URI shape below is a template, not a credential to paste unchanged.

URI scheme
postgresql://
Default PostgreSQL port
5432
Credential handling
Environment variable or secret manager
First test
psql "$DATABASE_URL" -c "select version();"

Connection string template

postgresql://postgres.PROJECT_REF:PASSWORD@aws-0-REGION.pooler.supabase.com:5432/postgres?sslmode=require

Replace every uppercase placeholder. Percent-encode reserved characters in URI usernames and passwords.

Environment variable

DATABASE_URL="postgresql://postgres.PROJECT_REF:PASSWORD@aws-0-REGION.pooler.supabase.com:6543/postgres?sslmode=require"

Where to get the Supabase values

Open the project dashboard and choose Connect. Supabase shows direct, session-pooler, and transaction-pooler strings. A desktop GUI needs a session-capable connection; a serverless runtime often benefits from transaction pooling.

The failure mode worth checking first

The direct endpoint is IPv6 by default on many projects. If your network is IPv4-only, use the shared pooler or the IPv4 add-on. Port 6543 is transaction mode and can conflict with features that depend on session state.

Test the connection

Run a cheap read-only command before migrations or application startup. That separates network, TLS, and authentication errors from framework configuration problems.

Connection check

psql "$DATABASE_URL" -c "select version();"

Open it in PostgresGUI

Paste the PostgreSQL URI into PostgresGUI or enter the same host, port, database, user, password, and SSL mode as separate fields. A desktop connection is useful for checking the visible schemas and role permissions before debugging the application layer.

Questions that come up

Should the connection string be committed to Git?

No. Commit an example with placeholders and load the real value from an environment variable or secret manager.

Why does a password with @ or # break the URI?

Those characters have meaning inside a URL. Percent-encode the username and password, or use a structured connection API instead of assembling a URL by hand.

Do I need sslmode=require?

Most hosted PostgreSQL services require TLS. For strict certificate and hostname verification, use sslmode=verify-full with the provider's trusted root certificate when the client supports it.

Keep going