Connection String Encoding
If your database password contains special characters, you must URL-encode them to avoid authentication errors like:
Error: SASL_SIGNATURE_MISMATCH: The server did not return the correct signatureError: password authentication failed for userGet Your Connection String
Section titled “Get Your Connection String”Before encoding, get your connection string from Supabase:
- Open Supabase Dashboard
- Navigate to Settings → Database
- Scroll to Connection String section
- Copy the Transaction Mode connection string (port 6543)
The string looks like:
postgresql://postgres.pooler-yourproject:[YOUR-PASSWORD]@aws-0-us-east-1.pooler.supabase.com:6543/postgresReplace [YOUR-PASSWORD] with your actual database password from the dashboard (you may need to reveal it first).
Common Characters That Need Encoding
Section titled “Common Characters That Need Encoding”Check if your password contains any of these characters:
| Character | Encoding | Character | Encoding |
|---|---|---|---|
@ | %40 | & | %26 |
: | %3A | / | %2F |
? | %3F | # | %23 |
% | %25 | (space) | %20 |
! | %21 | = | %3D |
Full encoding reference at MDN Web Docs
Encode Your Password
Section titled “Encode Your Password”Use the code examples below to encode your password on your own machine. These methods allow you to encode your credentials locally without sharing them with third-party services.
const encodedPassword = encodeURIComponent("my@complex&password!");console.log(encodedPassword);// Output: my%40complex%26password%21import urllib.parseencoded_password = urllib.parse.quote("my@complex&password!")print(encoded_password)# Output: my%40complex%26password%21# Requires jqencoded_password=$(printf %s "my@complex&password!" | jq -sRr @uri)echo $encoded_password# Output: my%40complex%26password%21Complete Example
Section titled “Complete Example”Here’s a realistic example showing the full process:
Original password from Supabase Dashboard:
P@ssw0rd!2024Encode just the password:
P%40ssw0rd%212024Original connection string:
postgresql://postgres.pooler-yourproject:P@[email protected]:6543/postgresEncoded connection string:
postgresql://postgres.pooler-yourproject:P%40ssw0rd%[email protected]:6543/postgresSet as Supabase Secret
Section titled “Set as Supabase Secret”Use the encoded connection string to set your database secret:
npx supabase secrets set EDGE_WORKER_DB_URL="postgresql://postgres.pooler-yourproject:P%40ssw0rd%[email protected]:6543/postgres"Replace the hostname, project name, and encoded password with your actual values.
Verify It Works
Section titled “Verify It Works”Test your connection by deploying and starting your worker:
npx supabase functions deploy your-worker-namecurl "https://your-project.supabase.co/functions/v1/your-worker-name" \ -H "Authorization: Bearer YOUR_ANON_KEY"If you see worker logs without authentication errors, the encoding worked.
For full deployment instructions, see Deploy Your First Flow.