PostgreSQL Connection String Generator

Generate connection strings for PostgreSQL in any format. JDBC, .NET, Python, Node.js, Go, and more.

Client-side only — nothing leaves your browser

postgresql://postgres:password@localhost:5432/mydb?sslmode=disable

What is a PostgreSQL Connection String?

A connection string contains all the information needed to connect to a PostgreSQL database: host address, port, database name, credentials, and SSL settings. Different programming languages and frameworks use different formats.

SSL Mode Options

  • disable — No SSL (not recommended for production)
  • require — Use SSL, don't verify certificate
  • verify-ca — Verify the server certificate is signed by a trusted CA
  • verify-full — Verify certificate and hostname match

Quick Reference

FormatExample Pattern
PostgreSQL URIpostgresql://user:pass@host:5432/db?sslmode=require
JDBC (Java)jdbc:postgresql://host:5432/db?user=user&password=pass
.NET / C#Host=host;Port=5432;Database=db;Username=user;Password=pass
Python (psycopg2)postgresql://user:pass@host:5432/db?sslmode=require
Node.js (pg)postgresql://user:pass@host:5432/db?sslmode=require
Go (lib/pq)host=host port=5432 dbname=db user=user password=pass
PHP (PDO)pgsql:host=host;port=5432;dbname=db;user=user;password=pass
Ruby (pg gem)postgresql://user:pass@host:5432/db?sslmode=require

Frequently Asked Questions

What's the difference between postgresql:// and postgres:// URI schemes?
Both postgresql:// and postgres:// are valid URI schemes for PostgreSQL connection strings. They are functionally identical — PostgreSQL accepts both. The postgresql:// format is the official standard per the documentation, while postgres:// is a common shorthand. Some libraries only recognize one form, so check your driver's documentation if you run into issues.
What SSL mode should I use for PostgreSQL?
For production environments, use 'require' at minimum to encrypt data in transit. Use 'verify-ca' or 'verify-full' for maximum security, which also validates the server's SSL certificate. Only use 'disable' for local development or trusted networks. Cloud providers like AWS RDS and Azure typically require 'require' or higher.
How do I escape special characters in a PostgreSQL password?
Special characters in passwords must be URL-encoded when using URI-style connection strings (postgresql://). For example, @ becomes %40, # becomes %23, : becomes %3A, and spaces become %20. Key-value formats like Go's lib/pq and .NET do not require encoding. Our generator automatically handles this encoding for you based on the selected format.
How do I find my PostgreSQL connection string in pgAdmin?
In pgAdmin, right-click on your server in the browser tree, select 'Properties', then look at the 'Connection' tab. You'll find the host, port, and maintenance database. Combine these with your username and password to form a connection string. For cloud-hosted databases (Supabase, Neon, AWS RDS), check your provider's dashboard for a pre-built connection string.
How do I connect to PostgreSQL in Docker?
Use the container name as the host when connecting from another container in the same Docker network (e.g., postgresql://user:pass@postgres-container:5432/db). From the host machine, use 'localhost' with the mapped port (e.g., localhost:5433 if you mapped 5433:5432). In Docker Compose, use the service name as the hostname.
PostgreSQL

Need a PostgreSQL GUI Client?

1bench is a modern database client for PostgreSQL and 20+ other databases. Query, browse, and manage your data visually.

Learn More