Use the PostgreSQL connection URI generated for your project and choose its direct, pooled, private, or public form according to where your app runs and how it opens connections. A URI has a familiar shape, but its host, username, port, database, and options are specific to the provider and resource. Do not build one from a generic example.
What a PostgreSQL connection string contains
A typical PostgreSQL URI looks like this:
postgresql://USER:PASSWORD@HOST:PORT/DATABASE?PARAMETER=VALUE
The scheme may be postgresql:// or postgres://. The username, password, hostname, port, and database identify the connection; query parameters can set options such as TLS. PostgreSQL documents both URI schemes at libpq connection strings. Driver support for URI options can vary, so consult your driver’s documentation if you split the URI into separate settings.
As an Amazon Associate I earn from qualifying purchases.
Use the exact value shown for the project, branch, role, database, and connection mode you intend to use. Replace any password placeholder, but not with its surrounding brackets. Reserved characters in a password must be percent-encoded so they are not interpreted as URI syntax.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Choose direct or pooled access based on the workload
Direct connections and poolers differ in reachability and connection behavior. A pooler can suit applications that create many short-lived connections, but some modes do not provide a dedicated database session. Before choosing, check where the client runs, whether the endpoint is reachable from there, and whether the driver or ORM needs session features such as prepared statements.
#1 Best Overall
Supabase: select a connection mode
Supabase offers direct connections and shared pooler modes. Copy the method-specific URI from the project’s dashboard; do not infer a pooler hostname from the region alone. Its connection guidance is at Supabase’s PostgreSQL connection guide.
| Mode | Best fit | Details to check |
|---|---|---|
| Direct | Persistent backends such as VMs and long-running containers | Uses port 5432. Direct connectivity is IPv6 unless the project has the IPv4 add-on. |
| Shared pooler, session mode | Clients needing session-style connections, including clients that need an IPv4 alternative to direct access | Uses port 5432, a generated pooler host, and a username that includes the project reference. |
| Shared pooler, transaction mode | Serverless or edge functions that create many short-lived connections | Uses port 6543. Prepared statements and query pipelining are not supported; disable prepared statements in clients that use them. |
| Dedicated pooler | Paid-plan workloads using transaction pooling | Available on paid plans in transaction mode; session mode uses the shared pooler. |
For serverless code, Supabase advises creating the client once at module scope, keeping the application’s own connection pool small, disabling prepared statements when using transaction mode, and requiring SSL. The application-side pool is separate from Supabase’s pooler, so size it with the function’s concurrency and connection limits in mind.
Rank #2
Neon: use the endpoint and role for the intended branch
Neon URIs follow the standard PostgreSQL format and include the role, password, host, database, and commonly sslmode=require. For applications that open many concurrent connections, Neon recommends the pooled URI; its hostname includes the -pooler suffix. The connection guide is at Neon’s connection guide.
Neon’s connection URI API can generate a URI with a pooled endpoint and lets you select a branch, endpoint, database, and role. Use the actual endpoint and credentials for that selection rather than copying an illustrative host. See Neon’s connection URI API reference.
Rank #3
Railway: use private variables inside the project or enable public access
Railway’s PostgreSQL service exposes PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE, and DATABASE_URL for project services. The database is private by default. Services in the same project environment can connect over Railway’s private network, using the service’s private hostname and connection variables. Railway documents this setup at Railway’s PostgreSQL guide and private networking guide.
To connect from outside Railway, enable public access in service networking. Railway then creates a TCP proxy and exposes DATABASE_PUBLIC_URL; use that external URL rather than the private in-project address. Keep the public endpoint protected by credentials and appropriate network controls.
If PgBouncer is enabled, Railway distinguishes pooled values (DATABASE_URL and DATABASE_PUBLIC_URL) from unpooled values (DATABASE_UNPOOLED_URL and DATABASE_PUBLIC_UNPOOLED_URL). Use the unpooled URI for work requiring a dedicated session. See Railway’s connection-pooling documentation.
Configure TLS deliberately
Do not assume that an SSL option means the server’s identity is verified. Supabase explains that sslmode=require encrypts the connection but does not verify the server identity. For certificate-based verification, its guide describes downloading the project’s root certificate and using sslmode=verify-full with sslrootcert. Check that the selected driver’s TLS settings support the parameters you use.
Keep credentials out of source code
Store the URI in an environment variable such as DATABASE_URL or use your platform’s managed variable references. Do not commit a literal database password in application code or a public repository. Railway reference variables can track service variables when they change; see Railway’s variables guide.
Quick Recap
Check these issues when a connection fails
- Wrong resource: confirm the URI belongs to the intended project, branch, role, database, and endpoint.
- Incorrect password syntax: replace the placeholder and percent-encode reserved password characters.
- Host or port mismatch: use the dashboard’s generated endpoint for the selected direct or pooled mode. For Supabase, do not derive the shared pooler host from the region name.
- Unsupported connection behavior: with Supabase transaction pooling, disable prepared statements and account for the documented transaction-pooling limitations.
- Railway address not reachable: use private variables from an in-project service; for an external client, enable public access and use
DATABASE_PUBLIC_URL. - TLS mismatch: check both the provider’s settings and the client driver’s TLS configuration. In Supabase’s explanation,
requireencrypts without verifying server identity.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




