Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use the PostgreSQL connection URI generated for your project and the way your application connects: direct or pooled for Supabase and Neon, and private or public for Railway. A typical URI looks like postgresql://USER:PASSWORD@HOST:PORT/DATABASE?PARAMETER=VALUE, but the host, username, port, database, and options vary by provider and connection mode. Copy the actual value from the provider’s dashboard or API rather than building it from an example.

What a PostgreSQL connection string contains

The URI format is postgresql://USER:PASSWORD@HOST:PORT/DATABASE?PARAMETER=VALUE. PostgreSQL also supports the postgres:// scheme form. The provider supplies the endpoint and credentials; the query string can carry options such as SSL settings. See the PostgreSQL connection string documentation.

When a password contains reserved characters, percent-encode those characters before putting it in a URI. Replace any password placeholder with the actual password, and do not include explanatory brackets from an example. If you translate the URI into separate driver settings, check that driver’s handling of connection parameters rather than assuming every client parses every libpq option identically.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a connection mode that fits your application

Make the choice based on where the application runs, whether it holds connections open, and whether its database client needs session-specific behavior.

Provider and mode Best fit Important details
Supabase 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.
Supabase shared pooler, session mode Applications needing a pooler, including as an IPv4 alternative when direct IPv6 access is unavailable Uses port 5432. Copy the generated pooler host and username, which includes the project reference.
Supabase shared pooler, transaction mode Serverless or edge functions that create many short-lived connections Uses port 6543. Does not support prepared statements or query pipelining.
Neon direct Applications that need a direct endpoint Use the actual project endpoint, database, role, and credentials shown by Neon.
Neon pooled Applications creating many concurrent connections The pooled hostname includes -pooler. Neon recommends the pooled URI for this workload.
Railway private connection A service running in the same Railway project environment Uses private connectivity and a hostname under .railway.internal; the database is private by default.
Railway public connection A client outside the Railway project network Requires enabling public access, which creates a TCP proxy and a DATABASE_PUBLIC_URL.

Get the right URI from Supabase

Supabase offers direct, session-pooler, and transaction-pooler connections. In the Supabase dashboard, open the project’s connection details and copy the URI for the selected method. Use that generated host and username: pooler hostnames cannot reliably be composed from a region alone, and a shared-pooler username differs from a direct-connection username. Follow the Supabase connection guide for the project-specific details.

For persistent backends

Choose direct connectivity for a long-running service when its network can reach the endpoint. The documented direct endpoint uses port 5432. Because direct connectivity is IPv6 unless the project has the IPv4 add-on, confirm your runtime’s network support before choosing this mode.

For serverless or edge functions

Use transaction pooling when many short-lived functions need database connections. Its documented port is 6543. Since this mode does not support prepared statements or query pipelining, configure the client accordingly; a client that uses prepared statements needs them disabled. Supabase also advises creating the client once at module scope and keeping the application-side pool limited. That application pool is separate from Supabase’s pooler.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For session pooling or dedicated pooling

The shared session pooler uses port 5432 and can provide an IPv4 path when direct IPv6 connectivity is unavailable. Paid plans also offer a dedicated pooler, but only in transaction mode; session mode uses the shared pooler.

Get the right URI from Neon

Use Neon’s connection flow to select the project, branch, endpoint, database, and role you intend to connect to, then copy the generated URI. Neon’s URI API can select a branch, endpoint, database name, and role name, and can include a pooler endpoint through its pooled option. See the Neon connection guide and connection URI API documentation.

For applications opening many concurrent connections, choose the pooled URI; its hostname has a -pooler suffix. Otherwise, use the direct URI if that matches the application’s connection needs. Neon’s connection guide shows sslmode=require in the URI; retain the provider-generated SSL setting unless your driver configuration requires a different documented setup.

Connect to Railway PostgreSQL privately or from outside

Railway exposes PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE, and DATABASE_URL for project services. A database is private by default. For in-project connectivity, use the private service variables or DATABASE_URL; Railway documents private hostnames under .railway.internal and a URI using the service hostname, port 5432, and database name. Private networking is scoped to the project environment. See the Railway PostgreSQL guide and private networking documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a client outside Railway, enable public access in the database service’s networking settings. This creates a TCP proxy and a DATABASE_PUBLIC_URL; use that public URL rather than the private connection value. If Railway’s PgBouncer feature is enabled, its documentation distinguishes pooled DATABASE_URL and DATABASE_PUBLIC_URL from unpooled DATABASE_UNPOOLED_URL and DATABASE_PUBLIC_UNPOOLED_URL. Use an unpooled value for work that needs a dedicated session. See Railway’s connection-pooling documentation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Set SSL deliberately and protect credentials

Encryption and server identity verification are not the same. Supabase explains that sslmode=require encrypts the connection but does not verify the server identity. For certificate-based verification, its documented setup uses sslmode=verify-full with the project root certificate specified through sslrootcert. Follow the Supabase SSL instructions and confirm that your driver supports the chosen URI options.

Keep connection credentials in environment variables or provider-managed references instead of committing a literal password to application source. Railway reference variables can track service variables when those values change; see its variables documentation.

Troubleshoot a connection that fails

  • Check that the URI belongs to the intended resource. Verify the project, database, role, and, for Neon, branch and endpoint in the provider’s connection flow.
  • Check the exact host, port, and username. Make sure they match the chosen direct or pooler mode. Do not infer a Supabase shared-pooler host from the region alone.
  • Check URI password encoding. Percent-encode reserved characters, and remove any placeholder brackets rather than treating them as part of the password.
  • Check connection semantics. With Supabase transaction mode, disable prepared statements and account for its other documented pooling limitations.
  • Check Railway network reachability. Use private variables from a service in the same project environment; from outside Railway, enable public access and use the public URL.
  • Check SSL configuration in the driver. Confirm that the driver accepts the options in the URI and that its TLS behavior matches the provider’s configuration.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.