Skip to content

Conversation

@transcaffeine
Copy link
Contributor

The commonly used location for sockets is /run/{service}, with /var/lib/{service} containing the actual data from the service.

@sfackler
Copy link
Collaborator

sfackler commented Mar 2, 2025

That may be true, but the commonly used location (in e.g. Ubuntu 24.04) for the Postgres socket is /var/lib/{service}.

@leona-ya
Copy link

leona-ya commented Mar 2, 2025

On a new Ubuntu 24.04 (with the standard repos) on a clean install I get the postgresql socket in /run/postgresql (equivalent to /var/run/postgresql):

root@testubuntu01:~# ls /var/run/postgresql/ -al
total 8
drwxrwsr-x  2 postgres postgres  100 Mar  2 20:21 .
drwxr-xr-x 31 root     root     1080 Mar  2 20:21 ..
srwxrwxrwx  1 postgres postgres    0 Mar  2 20:21 .s.PGSQL.5432
-rw-------  1 postgres postgres   70 Mar  2 20:21 .s.PGSQL.5432.lock
-rw-r--r--  1 postgres postgres    6 Mar  2 20:21 16-main.pid
root@testubuntu01:~# uname -a
Linux testubuntu01 6.8.0-52-generic #53-Ubuntu SMP PREEMPT_DYNAMIC Sat Jan 11 00:06:25 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
root@testubuntu01:~# cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.1 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian

@sfackler
Copy link
Collaborator

sfackler commented Mar 2, 2025

Sorry, yeah I misread /var/run as /var/lib. I'd prefer this use /var/run/postgresql instead of just /run to match with how psql is built:

root@80cc00b8042c:/# psql
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?
```

The commonly used location for sockets is `/run/{service}`, with
`/var/lib/{service}` containing the actual data from the service.
@transcaffeine
Copy link
Contributor Author

@sfackler i changed the paths to be all /var/run/postgresql :)

@paolobarbolini
Copy link
Member

On my Arch machine psql is in /run:

psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?

Should we instead document the fact that depending on the distro or the configuration it could be in different places?

@transcaffeine
Copy link
Contributor Author

With systemd expecting all PID etc under /run and the /var/run -> /run symlink being convention, i don't consider this necessary.

see https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s13.html

@paolobarbolini paolobarbolini merged commit bb7e0d0 into rust-postgres:master Sep 21, 2025
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

Successfully merging this pull request may close these issues.

4 participants