socket: address family not supported by protocol #14132

Open
opened 2025-11-02 11:03:51 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @JensTimmerman on GitHub (Feb 13, 2025).

Description

With the database config

[database]
DB_TYPE = postgres
HOST = /run/postgresql/
NAME = gitea
USER = gitea
PASSWD =  lel
SSL_MODE = disable
#PATH = /var/lib/gitea/data/gitea.db
LOG_SQL = true

I'm getting 2025/02/13 11:05:35 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol

Gitea Version

1.23.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

git version 2.43.5

Operating System

Rocky Linux release 9.4 (Blue Onyx)

How are you running Gitea?

deployed using https://github.com/roles-ansible/ansible_role_gitea in an lxc container on proxmox

Database

None

Originally created by @JensTimmerman on GitHub (Feb 13, 2025). ### Description With the database config ``` [database] DB_TYPE = postgres HOST = /run/postgresql/ NAME = gitea USER = gitea PASSWD = lel SSL_MODE = disable #PATH = /var/lib/gitea/data/gitea.db LOG_SQL = true ``` I'm getting `2025/02/13 11:05:35 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol` ### Gitea Version 1.23.3 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version git version 2.43.5 ### Operating System Rocky Linux release 9.4 (Blue Onyx) ### How are you running Gitea? deployed using https://github.com/roles-ansible/ansible_role_gitea in an lxc container on proxmox ### Database None
GiteaMirror added the type/proposal label 2025-11-02 11:03:52 -06:00
Author
Owner

@lunny commented on GitHub (Feb 13, 2025):

What's your postgres version?

@lunny commented on GitHub (Feb 13, 2025): What's your postgres version?
Author
Owner

@JensTimmerman commented on GitHub (Feb 13, 2025):

[jens@gitea ~]$ psql --version
psql (PostgreSQL) 13.14

I updated to 13.18 but no difference

[jens@gitea ~]$ psql --version
psql (PostgreSQL) 13.18
[root@gitea ~]# tail -f /var/lib/gitea/log/gitea.log
2025/02/13 22:10:47 ...eful/manager_unix.go:144:handleSignals() [W] PID 82022. Received SIGTERM. Shutting down...
2025/02/13 22:10:47 .../graceful/manager.go:168:doHammerTime() [W] Setting Hammer condition
2025/02/13 22:10:48 .../graceful/manager.go:184:doTerminate() [W] Terminating
2025/02/13 22:10:48 ...eful/manager_unix.go:154:handleSignals() [W] PID: 82022. Background context for manager closed - context canceled - Shutting down...
2025/02/13 22:10:49 ...es/setting/mailer.go:215:loadMailerFrom() [W] connecting over insecure SMTP protocol to non-local address is not recommended
2025/02/13 22:10:49 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol
2025/02/13 22:10:52 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #2/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol
2025/02/13 22:10:55 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #3/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol
2025/02/13 22:10:58 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #4/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol
2025/02/13 22:11:01 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #5/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol
2025/02/13 22:11:04 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #6/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol
2025/02/13 22:11:07 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #7/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol

pg_hba.conf contains

local all postgres    peer
local gitea gitea    trust

the gitea user can connect to the socket via local no password auth

[root@gitea ~]# sudo -u gitea psql -U gitea -d gitea -h /var/run/postgresql
could not change directory to "/root": Permission denied
psql (13.18)
Type "help" for help.

gitea=>

the socket file exists in the expected location

[root@gitea ~]# ls /run/postgresql/ -alh
total 4.0K
drwxr-xr-x  2 postgres postgres  80 Feb 13 22:11 .
drwxr-xr-x 21 root     root     580 Feb 13 22:10 ..
srwxrwxrwx  1 postgres postgres   0 Feb 13 22:11 .s.PGSQL.5432
-rw-------  1 postgres postgres  62 Feb 13 22:11 .s.PGSQL.5432.lock

This worked last month, broke after update to 1.23.3, it worked on 1.22 IIRC, I can try to do a disect in the coming days.

Commenting out the password in the ini file has no effect

it works if I add this to ph_hba.conf

host    all     gitea     127.0.0.1/32    trust

and change host in ini to HOST = 127.0.0.1
but I prefer to use the unix socket vs tcp, since that's how I configure postgres on all my other services and that worked for years until this update.

@JensTimmerman commented on GitHub (Feb 13, 2025): ``` [jens@gitea ~]$ psql --version psql (PostgreSQL) 13.14 ``` I updated to 13.18 but no difference ``` [jens@gitea ~]$ psql --version psql (PostgreSQL) 13.18 ``` ``` [root@gitea ~]# tail -f /var/lib/gitea/log/gitea.log 2025/02/13 22:10:47 ...eful/manager_unix.go:144:handleSignals() [W] PID 82022. Received SIGTERM. Shutting down... 2025/02/13 22:10:47 .../graceful/manager.go:168:doHammerTime() [W] Setting Hammer condition 2025/02/13 22:10:48 .../graceful/manager.go:184:doTerminate() [W] Terminating 2025/02/13 22:10:48 ...eful/manager_unix.go:154:handleSignals() [W] PID: 82022. Background context for manager closed - context canceled - Shutting down... 2025/02/13 22:10:49 ...es/setting/mailer.go:215:loadMailerFrom() [W] connecting over insecure SMTP protocol to non-local address is not recommended 2025/02/13 22:10:49 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol 2025/02/13 22:10:52 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #2/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol 2025/02/13 22:10:55 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #3/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol 2025/02/13 22:10:58 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #4/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol 2025/02/13 22:11:01 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #5/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol 2025/02/13 22:11:04 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #6/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol 2025/02/13 22:11:07 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #7/10 failed. Error: dial unix /run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol ``` pg_hba.conf contains ``` local all postgres peer local gitea gitea trust ``` the gitea user can connect to the socket via local no password auth ``` [root@gitea ~]# sudo -u gitea psql -U gitea -d gitea -h /var/run/postgresql could not change directory to "/root": Permission denied psql (13.18) Type "help" for help. gitea=> ``` the socket file exists in the expected location ``` [root@gitea ~]# ls /run/postgresql/ -alh total 4.0K drwxr-xr-x 2 postgres postgres 80 Feb 13 22:11 . drwxr-xr-x 21 root root 580 Feb 13 22:10 .. srwxrwxrwx 1 postgres postgres 0 Feb 13 22:11 .s.PGSQL.5432 -rw------- 1 postgres postgres 62 Feb 13 22:11 .s.PGSQL.5432.lock ``` This worked last month, broke after update to 1.23.3, it worked on 1.22 IIRC, I can try to do a disect in the coming days. Commenting out the password in the ini file has no effect it works if I add this to ph_hba.conf ``` host all gitea 127.0.0.1/32 trust ``` and change host in ini to `HOST = 127.0.0.1` but I prefer to use the unix socket vs tcp, since that's how I configure postgres on all my other services and that worked for years until this update.
Author
Owner

@lunny commented on GitHub (Feb 26, 2025):

This has never been supported. So I believe it should be classified as a proposal rather than a bug.

@lunny commented on GitHub (Feb 26, 2025): This has never been supported. So I believe it should be classified as a proposal rather than a bug.
Author
Owner

@JensTimmerman commented on GitHub (Feb 26, 2025):

@lunny the documentation states:

HOST: 127.0.0.1:3306: Database host address and port or absolute path for unix socket [mysql, postgres[1](https://docs.gitea.com/administration/config-cheat-sheet#user-content-fn-1)] (ex: /var/run/mysqld/mysqld.sock).

and this has worked for years.

This piece of documentation points to an issue that shows that it worked for others:
https://github.com/go-gitea/gitea/issues/24552#issuecomment-1681649367

This comment doesn't solve the issue for me, as I'm using the default port, and setting

HOST = /var/run/postgresql:5432

or

HOST = /var/run/postgresql

both give me the same error

2025/02/27 07:10:34 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #6/10 failed. Error: dial unix /var/run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol
2025/02/27 07:10:37 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #7/10 failed. Error: dial unix /var/run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol
2025/02/27 07:10:40 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #8/10 failed. Error: dial unix /var/run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol
@JensTimmerman commented on GitHub (Feb 26, 2025): @lunny the documentation states: ``` HOST: 127.0.0.1:3306: Database host address and port or absolute path for unix socket [mysql, postgres[1](https://docs.gitea.com/administration/config-cheat-sheet#user-content-fn-1)] (ex: /var/run/mysqld/mysqld.sock). ``` and this has worked for years. This piece of documentation points to an issue that shows that it worked for others: https://github.com/go-gitea/gitea/issues/24552#issuecomment-1681649367 This comment doesn't solve the issue for me, as I'm using the default port, and setting ``` HOST = /var/run/postgresql:5432 ``` or ``` HOST = /var/run/postgresql ``` both give me the same error ``` 2025/02/27 07:10:34 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #6/10 failed. Error: dial unix /var/run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol 2025/02/27 07:10:37 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #7/10 failed. Error: dial unix /var/run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol 2025/02/27 07:10:40 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #8/10 failed. Error: dial unix /var/run/postgresql/.s.PGSQL.5432: socket: address family not supported by protocol ```
Author
Owner

@lunny commented on GitHub (Feb 26, 2025):

I will take a look at this

@lunny commented on GitHub (Feb 26, 2025): I will take a look at this
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14132