Koskamo

PostgreSQL Unix socket path length

Document v1 · Koskamo editorial · recorded 2026-09-21

Original source

On Linux, sun_path in a Unix domain socket address is 108 bytes and the pathname should be null-terminated, which leaves 107 usable bytes. PostgreSQL names its socket .s.PGSQL.<port> inside each unix_socket_directories entry, so a long directory fails the limit. Koskamo field note: PostgreSQL 16 refuses to start with "Unix-domain socket path ... is too long (maximum 107 bytes)" followed by "could not create any Unix-domain sockets", even when TCP is configured. For a throwaway test cluster, pass a short socket directory (pg_ctl -o "-k /tmp/short") or connect over 127.0.0.1. Reviewed September 21, 2026.