Connection configuration and security

Database URL: Formats, Examples, and Safe Setup

Learn how to read, build, protect, and troubleshoot database URLs across PostgreSQL, MySQL, SQL Server, Oracle, and MongoDB—without turning credentials into a security incident.

16-minute readVerified July 24, 2026
A sanitized database URL is separated into protocol, identity, host, port, database, and options while credentials move into a secure vault
On this page

What is a database URL?

A database URL is a structured locator that tells a client how and where to open a database connection. It normally identifies the database protocol or driver, host, port, database or service, and optional connection behavior such as TLS. Some formats can include a username and password, but production systems should retrieve secrets separately at runtime.

A URL that looks correct is not proof that a database is reachable or that login will succeed. Syntax, DNS, routing, firewall rules, TLS, authentication, authorization, and database selection are separate checks. Treat the URL as configuration, then validate the connection layer by layer.

SchemeProtocol or driver family
HostResolvable endpoint
PortListening service
PathDatabase or service

Database URL, URI, and connection string are related—not identical

Developers often use these names interchangeably because all three carry connection details. The difference matters when copying a value between a cloud console, framework, driver, command-line client, and application.

TermPractical meaningTypical shape
Database URLA location-oriented connection value with a scheme and endpoint.postgresql://host:5432/app
Database URIA broader identifier term. In practice, many database URIs use URL syntax.mongodb+srv://cluster/app
Connection stringAny driver-supported serialization of connection properties; it may not follow generic URI syntax.Server=host;Database=app;...

Rule: use the format documented by the exact driver and version your application loads. A PostgreSQL URI cannot be converted to a SQL Server JDBC URL by replacing only the scheme.

Read a database URL from left to right

Sanitized PostgreSQL example
postgresql://app_user@db.example.internal:5432/analytics?sslmode=require
  1. Scheme or subprotocolpostgresql, mysql, mongodb, or a JDBC prefix selects a compatible parser and driver. An unsupported scheme can fail before any network request occurs.
  2. User informationThe portion before @ may identify a user and sometimes a password. Avoid embedding the password. If a framework requires one combined value, assemble it at runtime and keep it out of logs.
  3. HostThe hostname must resolve from the application network. Private endpoints may work inside a VPC or VPN but fail from a laptop or public checker.
  4. PortThe port identifies the listening service. Common defaults are 5432 for PostgreSQL, 3306 for MySQL, 1433 for SQL Server, and 1521 for Oracle, but managed services can use different values.
  5. Path or database selectorDepending on the vendor, the path may select a database, service, or initial catalog. Do not assume a schema name belongs here.
  6. Query options or propertiesTLS mode, timeouts, application name, read preference, and other behaviors live here. Property names and safe defaults are driver-specific.

Database URL formats and sanitized examples

These examples explain structure; they are not universal copy-and-paste production settings. Confirm driver syntax, TLS policy, and authentication method in the current vendor documentation.

DatabaseSanitized formatImportant distinction
PostgreSQLpostgresql://user@host:5432/db?sslmode=requirelibpq accepts URI and keyword/value forms.
MySQL JDBCjdbc:mysql://host:3306/db?sslMode=VERIFY_IDENTITYConnector/J uses a JDBC subprotocol and driver properties.
SQL Server JDBCjdbc:sqlserver://host:1433;databaseName=db;encrypt=trueProperties are commonly semicolon-delimited, not URI query pairs.
Oracle Thin JDBCjdbc:oracle:thin:@//host:1521/serviceService-name and SID formats differ; use the one your administrator provides.
MongoDB SRVmongodb+srv://user@cluster.example/db?tls=trueSRV discovery can supply hosts and ports through DNS records.

A framework may expect a wrapper around these values. SQLAlchemy, Prisma, Spring, and cloud SDKs can impose their own prefixes or parameter rules. Verify both the database driver's format and the framework adapter's format.

How to find your database URL without copying the wrong address

  1. Open the database connection detailsIn a managed service, look for “Connect,” “Endpoint,” “Connection info,” or “Networking.” The browser address of the administration console is not the database URL.
  2. Choose the application pathSelect public, private, proxy, pooler, or read-replica endpoints according to the deployment architecture. The right endpoint for a local client may be wrong for a production workload.
  3. Copy components separatelyRecord database type, host, port, database or service name, required TLS mode, and authentication method. Keep the password in a secret manager.
  4. Assemble for the actual driverUse the driver documentation instead of converting another tool's example by intuition. Test in a non-production environment from the same network path as the application.

Percent-encode reserved characters—but do not hide unsafe design

Characters such as @, :, /, ?, #, and % have structural meaning in URI syntax. If a username or password contains a reserved character and the driver accepts credentials in the URL, that component may require percent-encoding. Encode the component—not the complete URL—and never encode it twice.

Security warning: percent-encoding is syntax handling, not encryption. A password encoded as %40 instead of @ is still a password and can be recovered. The safer design is a secret manager, runtime injection, redacted logs, and short-lived or rotated credentials.

Test a database URL as a sequence of independent claims

Do not paste a production URL containing secrets into an unknown website. Redact credentials first, identify the database type, then extract the host and port. Test from the network where the application runs.

CheckWhat success provesWhat it does not prove
ParseThe value matches the parser's expected grammar.Endpoint reachability or valid credentials.
DNSThe hostname resolves in that environment.A database listens on the resolved address.
TCPA network path reaches a listening endpoint.TLS, login, permissions, or query execution.
TLSThe client and server agree on protected transport.The database identity has access.
AuthenticationThe server accepts the supplied identity.Required schema access or workload reliability.

Check the host and port behind your database URL

Extract the authorized host and port, then use the InfiniSynapse DB Compatibility Checker. PostgreSQL, MySQL, MariaDB, Redshift, and CockroachDB support a one-time authentication test. Snowflake, ClickHouse, Databricks, SQL Server, Oracle, and MongoDB are checked for TCP reachability only. Interpret the result according to the test type.

Open DB Compatibility Checker Use approved, temporary, or least-privilege credentials. A TCP pass does not validate TLS, login, permissions, database selection, or queries.

Why a database URL fails and what to inspect next

SymptomLikely causeUseful next step
Unknown scheme or no suitable driverWrong URL prefix, missing driver, or framework adapter mismatch.Verify installed driver, version, and required subprotocol.
Malformed URLMissing separator, incorrect slash/semicolon form, or an unescaped reserved character.Compare component-by-component with current driver documentation.
Host not foundTypo, private DNS, missing VPN, or wrong environment endpoint.Resolve the host from the application network.
Connection refused or timed outWrong port, listener down, route/firewall block, or endpoint not exposed to this source.Check assigned port and TCP reachability from the actual source.
Certificate or TLS errorWrong hostname, untrusted CA, expired certificate, or incompatible TLS property.Inspect certificate name, chain, trust store, and driver TLS mode.
Password works elsewhere but fails in URLReserved characters were not encoded, were double-encoded, or were parsed as delimiters.Prefer separate secret fields; otherwise encode only the credential component.
Database or service not foundDatabase, schema, SQL Server instance, Oracle SID, and service name were confused.Confirm the selector type with the database administrator.
Works locally but fails in a containerlocalhost refers to the container itself, or container DNS/routes differ.Use the service DNS name and test inside the workload environment.

Secure database URLs through their full lifecycle

  • Keep secrets out of source control: store credentials in a secret manager or protected runtime configuration, not code, screenshots, tickets, or documentation examples.
  • Redact observability data: remove user information and sensitive query parameters before URLs enter logs, traces, errors, analytics, or crash reports.
  • Use least privilege: separate migration, administration, read-only, and application identities. A connectivity test should not use an owner account.
  • Require verified TLS: encrypt transport and verify the server identity. Avoid disabling certificate checks merely to make an error disappear.
  • Rotate and revoke: treat every accidentally exposed URL as a possible credential incident. Remove the exposure, rotate the secret, revoke sessions if supported, and inspect access records.

A production-ready database URL validation checklist

Format

Correct scheme, driver version, separators, path semantics, and option names.

Endpoint

Environment-specific host, assigned port, resolvable DNS, and intended private/public path.

Trust

TLS required, certificate verified, CA available, and hostname matches.

Secrets

No hardcoded password, runtime injection works, output is redacted, and rotation is documented.

Permissions

Identity can connect only to the required database and perform only the required operations.

Evidence

DNS, TCP, TLS, login, and a harmless health query are tested from the application environment.

For the broader network and session model behind these checks, continue with the database connection and connectivity guide.

Database URL FAQ

What is a database URL?

It is a structured connection locator containing a protocol or driver, host, port, database or service, and optional connection properties.

Is a database URL the same as a connection string?

They overlap, but not every connection string is a URI. PostgreSQL and MongoDB often use URI-style values, while SQL Server and Oracle JDBC use vendor-specific structures.

Should a database URL contain a password?

Prefer not to embed it. URLs can leak through repositories, logs, process inspection, crash reports, and monitoring. Retrieve the secret securely at runtime.

How do I find my database URL?

Use the endpoint details provided by your database administrator or managed-service connection panel, then construct the value using the exact driver format.

Why does a valid-looking database URL fail?

Syntax can be valid while DNS, routing, firewall, TLS, credentials, permissions, database selection, or driver properties are wrong.

How can I test a database URL safely?

Redact credentials, extract the authorized host and port, test reachability, then use a least-privilege account for TLS, authentication, authorization, and a harmless query.

Official database URL and security references