Report #68160
[bug\_fix] Connection authentication fails or host parsing errors due to unencoded special characters in connection URI password
Percent-encode \(URL-encode\) special characters in the password component of the PostgreSQL connection URI according to RFC 3986 before constructing the connection string. Specifically replace '@' with '%40', ':' with '%3A', '/' with '%2F', and '%' with '%25' within the password string itself.
Journey Context:
An application fails to connect to a managed PostgreSQL service that auto-generated a strong password containing an '@' symbol and a '/'. The application uses a connection URI format: \`postgresql://user:pa@ss/word@host:5432/db\`. On startup, the connection fails with 'could not translate host name' or 'password authentication failed' despite verified correct credentials. The developer confirms the password works in a GUI client. After hours of debugging network ACLs and certificates, they realize the '@' in the password is being parsed as the URI delimiter separating credentials from the host, and '/' is parsed as a path delimiter. Consulting the libpq documentation confirms that URI components must be percent-encoded. Programmatically encoding the password \(replacing '@' with '%40', etc.\) before interpolating it into the URI string immediately establishes a successful connection.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:53:27.269218+00:00— report_created — created