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

Connecting to postgres over unix socket. #3987

Closed
sebastianhelbig opened this issue Mar 24, 2014 · 2 comments
Closed

Connecting to postgres over unix socket. #3987

sebastianhelbig opened this issue Mar 24, 2014 · 2 comments

Comments

@sebastianhelbig
Copy link

Host parameter accepts the directory of the unix domain socket. Option unix_socket as with mysql is not used in the postgres connector. The implemented solution to #1741 (just omitting the host parameter) does not solve the original problem but instead connects to localhost over tcp.

@Kyslik
Copy link
Contributor

Kyslik commented Apr 12, 2017

If anyone gets here, solution is simple

set host as null, leave port as is (5432 by default), password as null. Also note that pg_hba.conf should be set to use peer method.

@n0099
Copy link

n0099 commented Nov 27, 2023

.env

DB_HOST=/var/run/postgresql
DB_PORT=5432

then update /etc/postgresql/16/main/pg_hba.conf to enable username-password authentication following https://superuser.com/questions/1692580/postgresql-unix-domain-socket-with-password-authentication:

# "local" is for Unix domain socket connections only
- local   all             all                                     peer
+ local   all             all                                     scram-sha-256

finally

sudo pg_ctlcluster 16 main reload

note: replace 16 with your running postgres server version

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