-
Notifications
You must be signed in to change notification settings - Fork 8
bug(connection): 'connection failed: db error' swallows actual error cause #707
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Report
@mlusetti reported on X (2026-03-22): 'Tried it today but simply got "connection failed: db error" with every connection syntax I tried. Even -D option did not produce meaningful output. Classic psql connect smoothly.'
Root cause
In src/connection.rs, map_connect_error() calls e.to_string() on a tokio_postgres::Error. When the error is not a DB-level error (e.g. TCP refused, wrong hostname, network timeout), tokio-postgres displays it as "db error" — the actual cause is buried in the error source chain.
Fix: walk e.source() chain to extract the real underlying IO/network error when e.as_db_error() is None.
Expected
connection to server at "localhost", port 5432 failed: Connection refused (os error 111)
Actual
connection to server at "localhost", port 5432 failed: db error
Additional: -D should show more
The -D flag should print the full error chain including source. Currently doesn't help diagnose connection failures.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working