According to https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS
The default behavior when host is not specified, or is empty, is to connect to a Unix-domain socket in /tmp (or whatever socket directory was specified when PostgreSQL was built). On Windows, the default is to connect to localhost.
However tokio-posgres connect prevents host & hostaddr being omitted:
https://github.com/sfackler/rust-postgres/blob/02463b1/tokio-postgres/src/connect.rs#L20-L22
Activity
sfackler commentedon May 18, 2025
Correct, the client does not implement that since it doesn't know what socket directory was specified when PostgreSQL was built.
jayvdb commentedon May 18, 2025
On non-Windows, the pg client default is
/tmp/.s.PGSQL.5432, however as you indicate it can be changed at the time the client is built.On Windows, the default if it missing is
host=localhost.Can appreciate you may not want to support this.
I see on https://docs.rs/tokio-postgres/latest/tokio_postgres/config/struct.Config.html it says regarding
hostPerhaps that should be revised to say something like
And perhaps move that up to the top, so it is more prominent.
Interestingly under "Url" it says
How then does this client connect if all components of the Url are missing?