Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncommon syntax for unix socket connections #297

Open
Caian opened this issue Dec 29, 2024 · 3 comments
Open

Uncommon syntax for unix socket connections #297

Caian opened this issue Dec 29, 2024 · 3 comments

Comments

@Caian
Copy link

Caian commented Dec 29, 2024

The only way to connect to my socket is by passing ?host=/postgres/.s.PGSQL.5432 to my database URL. This is quite unusual as all pieces of software I've worked so far used the socket directory instead. Is this the expected behavior?

@will
Copy link
Owner

will commented Dec 29, 2024

I copied how libpq does it: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-HOST

host
Name of host to connect to. If a host name looks like an absolute path name, it specifies Unix-domain communication rather than TCP/IP communication; the value is the name of the directory in which the socket file is stored. (On Unix, an absolute path name begins with a slash.

@bcardiff
Copy link
Collaborator

You can also use PGHOST env variable and leave the connection string almost empty.

See last spec of conninfo_spec.

@Caian
Copy link
Author

Caian commented Dec 29, 2024

I copied how libpq does it: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-HOST

host
Name of host to connect to. If a host name looks like an absolute path name, it specifies Unix-domain communication rather than TCP/IP communication; the value is the name of the directory in which the socket file is stored. (On Unix, an absolute path name begins with a slash.

Hi Will, in libpq-connect host is passed as a directory containing the socket, not the socket itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants