[ZBX-7795] PostgreSQL unix sock connections issues Created: 2014 Feb 12  Updated: 2019 Dec 10

Status: Open
Project: ZABBIX BUGS AND ISSUES
Component/s: Documentation (D)
Affects Version/s: 2.2.1
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Don Conry Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: PostgreSQL, regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

openSUSE 12.3
PostgreSQL 9.2-2.1.1



 Description   

I encountered a problem during upgrade from Zabbix server 2.0.9 to 2.2.1, via openSUSE monitoring repo packages. Previously Zabbix (2.0.7, 2.0.8, & 2.0.9) was connecting using a unix-style socket file (instead of a listening network socket). After upgrading, this type of connection seems to be failing - from the server log:

-------------------------
13632:20140204:174820.079 Database is down. Reconnecting in 10 seconds.
13632:20140204:174830.080 [Z3001] connection to database 'zabbix' failed: [0] could not connect to server: No such file or directory
Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
-------------------------

Note this /tmp/.s.PGSQL.5432 file does exist, with proper permissions. While troubleshooting this, I verified that SELinux is not active, that I can connect using psql (command line tool), and that PostgreSQL & Zabbix server ARE actually running. Since no postgres config changed were made during the upgrade, I suspect this may be due to a change in Zabbix 2.2 branch.

Previously I'd followed instructions for the zabbix-server.conf file for using unix sockets with Zabbix, by setting DBHost to blank. Relevant snippet below:

--------------
DBHost=
DBName=zabbix
DBUser=zabbix
DBSocket=/tmp/.s.PGSQL.5432
--------------

At this point I am wondering if the syntax in zabbix-server.conf required to force Unix domain socket connections has changed, or is broken, between 2.0.9 and 2.2.1. I've tried fiddling with different combos of this syntax, but so far no luck.

For now I've allowed Postgres to listen on localhost via network socket, and am (successfully) allowing Zabbix to connect that way instead. The database was upgraded properly & new setup is (mostly) working, but I'd like to go back to using Unix sockets if possible.

I've searched for similar existing bugs, but not found any recent related to this. Am willing to help troubleshoot with add'tl info/testing as needed. Thanks!



 Comments   
Comment by Don Conry [ 2014 Feb 12 ]

One more item of info, zabbix server version was initially upgraded to 2.2.1-2.1 from repo, has since been upgraded to 2.2.1-4.1.

Comment by Don Conry [ 2014 Feb 12 ]

Also, this may be related to ZBX-7610. Will test 2.2.2 when I can...

Comment by Aleksandrs Saveljevs [ 2014 Feb 13 ]

Note that DBSocket parameter is only used for MySQL:

### Option: DBSocket
#	Path to MySQL socket.
#
# Mandatory: no
# Default:
# DBSocket=/tmp/mysql.sock
Comment by Don Conry [ 2014 Feb 20 ]

Upgraded to 2.2.2 via openSUSE monitoring repo this morning... no change i.e. config that was working in 2.0.9 is producing connection errors in 2.2.2. I also tried both with & without the DBSocket parameter, seems to have no effect (which is probably expected, since it applies only to MySQL).

The error in Zabbix Server log on startup is same as above, even though that sock file exists with permissions & PGSQL config unchanged from working system w/Zabbix 2.0.9:

srwxrwxrwx 1 postgres postgres 0 Feb 20 13:54 .s.PGSQL.5432

Will continue testing the newest release using all combinations of parameters, & hopefully find a working config. For now, Zabbix Server is connecting via localhost:5432.

Comment by Eugene Istomin [ 2014 Feb 21 ]

The same problem,

OpenSUSE 13.1, Zabbix server v2.2.2, PostgreSQL 9.3.2

9063:20140221:104418.566 Database is down. Reconnecting in 10 seconds.
9063:20140221:104428.566 [Z3001] connection to database 'zabbix' failed: [0] could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

DBHost=
DBName=zabbix
DBUser=zabbix
DBPassword=XXX
DBSocket=/tmp/.s.PGSQL.5432

Comment by Don Conry [ 2014 Mar 10 ]

I believe I have discovered the cause of this. OpenSUSE implementation bug, see e.g. https://bugzilla.novell.com/show_bug.cgi?id=857459

Fix for me was:

1) Edit /usr/lib/systemd/system/zabbix-server.service
2) Change line:
PrivateTmp=true
to:
PrivateTmp=false

Thank you, Lennart Poettering. I will see about contacting the OpenSUSE packager to get this incorporated in the next package build.

Comment by Don Conry [ 2014 Mar 11 ]

Add'tl notes: after making the edit above, you'll need to poke systemd and then restart the zabbix server. Don't forget to set 'DBHost=' in Zabbix server config file first.

1) systemctl daemon-reload
2) systemctl restart zabbix-server

Comment by richlv [ 2014 Mar 11 ]

thanks for the update. can somebody else who had this problem try the solution from don ?
if that works, we might want to document it in troubleshooting section, probably

Comment by Don Conry [ 2014 Apr 16 ]

Just a note, it is possible to work around this by moving the PostgreSQL sock file from the default /tmp to a different location which is not affected by the systemd PrivateTmp 'feature'.

Took a moderate amount of trial & error to figure out the proper syntax everywhere, the steps are listed as a reply to my original forum post here:

https://www.zabbix.com/forum/showthread.php?t=44140

Comment by Marc [ 2018 Jan 09 ]

richlv,
I can also confirm that this did the trick on CentOS 7:

# mkdir /etc/systemd/system/httpd.service.d
# cat > /etc/systemd/system/httpd.service.d/noprivtmp.conf << EOF
[Service]
PrivateTmp=false
EOF
# systemctl daemon-reload
# systemctl restart httpd

Special thanks to dconry without whose comment I'd possibly never have found out about PrivateTmp!

Generated at Wed May 28 06:59:15 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.