laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.33k stars 10.96k forks source link

Connecting to postgres over unix socket. #3987

Closed sebastianhelbig closed 10 years ago

sebastianhelbig commented 10 years ago

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 commented 7 years ago

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 commented 10 months ago

.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