Skip to content

Commit 654efbf

Browse files
committed
Add a section on socket communication for postgrex
1 parent 4c5776d commit 654efbf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/ecto/adapters/postgres.ex

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,30 @@ defmodule Ecto.Adapters.Postgres do
126126
127127
config :my_app, MyApp.Repo, types: MyApp.PostgresTypes
128128
129+
## Unix socket connection
130+
131+
You may desire to communicate with Postgres via Unix sockets.
132+
If your PG server is started on the same machine as your code, you could check that:
133+
134+
```bash
135+
% sudo grep unix_socket_directories /var/lib/postgres/data/postgresql.conf
136+
unix_socket_directories = '/run/postgresql'
137+
```
138+
139+
```bash
140+
% ls -lah /run/postgresql
141+
итого 4,0K
142+
drwxr-xr-x 2 postgres postgres 80 июн 4 10:58 .
143+
drwxr-xr-x 35 root root 840 июн 4 21:02 ..
144+
srwxrwxrwx 1 postgres postgres 0 июн 5 07:41 .s.PGSQL.5432
145+
-rw------- 1 postgres postgres 61 июн 5 07:41 .s.PGSQL.5432.lock
146+
```
147+
148+
So you have postgresql started and listening on the socket.
149+
Then you may use it as follows:
150+
151+
config :your_app, YourApp.Repo,
152+
socket_dir: "/run/postgresql"
129153
"""
130154

131155
# Inherit all behaviour from Ecto.Adapters.SQL

0 commit comments

Comments
 (0)