• 4
name Punditsdkoslkdosdkoskdo

Zabbix can't connected to a PostgreSQL database

First off I am running CentOS 6.5 and attempting to use Zabbix 2.2.4. Any hostnames have been replaced with examples.

I have installed the following RPMs onto my Zabbix machine ( hostname will be zbx-hostname ):


My PostgreSQL machine has postgreSQL 9.2 installed with the RPMS ( hostname will be db-hostname ):


My zabbix_server.conf file looks like:


My zabbix php configuration looks like:

$DB['SERVER']   = 'db-hostname';
$DB['PORT']     = '5432';
$DB['DATABASE'] = 'zabbix-dbname';
$DB['USER']     = 'zabbix-user';
$DB['PASSWORD'] = 'zabbix-password';

// SCHEMA is relevant only for IBM_DB2 database
$DB['SCHEMA'] = '';

$ZBX_SERVER      = 'localhost';
$ZBX_SERVER_PORT = '10051';


I am able to run the following and successfully connect to my database:

export PGPASSWORD=zabbix; psql -U zabbix-user -d zabbix-dbname -h db-hostname
export PGPASSWORD=zabbix; psql -U zabbix-user -d zabbix-dbname -h

But zabbix refuses to connect printing out ( being the correctly resolved IP Address) :

25015:20150205:112656.236 [Z3001] connection to database 'zabbix-dbname' failed: [0] could not connect to server: Permission denied
    Is the server running on host "db-hostname" ( and accepting
    TCP/IP connections on port 5432?

25015:20150205:112656.236 Database is down. Reconnecting in 10 seconds.

But on the DB host when I monitor incomming TCP traffic I do not see any incoming connections ( using both tcpdump & iptables ). It appears that zabbix is not even attempting to make a request to the database box?

I have torndown my zabbix box and rebuit it to get the same error twice so it would appear to be a problem with my configuration, does anybody know of any solutions?

In my situation I need to grant network access for httpd too. (CentOS 7, zabbix 3)

sudo setsebool -P httpd_can_network_connect_db 1
sudo setsebool -P httpd_can_network_connect 1

If you have error "setsebool, command not found" install policycoreutils-python

yum install policycoreutils-python
  • 1
Reply Report

I am going through the steps to compile/install the Zabbix server from the 2.4 documentation. I've already configured the installation with the correct options to support PostgreSQL:


./configure --enable-server --enable-agent --with-postgresql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-ldap --with-openipmi --with-ssh2 --with-jabber --with-unixodbc

Our DBA has also already configured a database for our Zabbix server to connect to, and I've verified it from the Zabbix server with psql:


[email protected]:/usr/local/etc$ psql -h <dbhost> -p <dbport> -U zabbix zabbix
password for user zabbix:
psql (9.4.5)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 zabbix    | zabbix   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(4 rows)

So clearly psql client can connect with the zabbix db username/pw.

The required parts of the zabbix_server.conf are set up as such:



As soon as I fire up zabbix_server from /usr/local/sbin/, in the log I see the following error messages:


83651:20160107:132034.628 Starting Zabbix Server. Zabbix 2.4.7 (revision 56694).
 83651:20160107:132034.628 ****** Enabled features ******
 83651:20160107:132034.629 SNMP monitoring:           YES
 83651:20160107:132034.629 IPMI monitoring:           YES
 83651:20160107:132034.629 WEB monitoring:            YES
 83651:20160107:132034.629 VMware monitoring:         YES
 83651:20160107:132034.629 Jabber notifications:      YES
 83651:20160107:132034.629 Ez Texting notifications:  YES
 83651:20160107:132034.629 ODBC:                      YES
 83651:20160107:132034.629 SSH2 support:              YES
 83651:20160107:132034.629 IPv6 support:              YES
 83651:20160107:132034.629 ******************************
 83651:20160107:132034.629 using configuration file: /usr/local/etc/zabbix_server.conf
 83651:20160107:132034.629 In load_modules()
 83651:20160107:132034.629 End of load_modules():SUCCEED
 83651:20160107:132034.629 In init_database_cache()
 83651:20160107:132034.629 In zbx_mem_required_size() size:0 chunks_num:4 descr:'history cache' param:'HistoryCacheSize'
 83651:20160107:132034.629 End of zbx_mem_required_size() size:543
 83651:20160107:132034.629 In zbx_mem_create() descr:'history cache' param:'HistoryCacheSize' size:8388583
 83651:20160107:132034.629 zbx_shmget() removing existing shm_id:1310728
 83651:20160107:132034.629 valid user addresses: [0x7f50a2ba0170, 0x7f50a339ffd8] total size: 8388200
 83651:20160107:132034.629 End of zbx_mem_create()
 83651:20160107:132034.629 In zbx_mem_required_size() size:0 chunks_num:1 descr:'history text cache' param:'HistoryTextCacheSize'
 83651:20160107:132034.629 End of zbx_mem_required_size() size:435
 83651:20160107:132034.629 In zbx_mem_create() descr:'history text cache' param:'HistoryTextCacheSize' size:16777216
 83651:20160107:132034.629 zbx_shmget() removing existing shm_id:1343497
 83651:20160107:132034.629 valid user addresses: [0x7f50a1ba0178, 0x7f50a2b9fff0] total size: 16776824
 83651:20160107:132034.629 End of zbx_mem_create()
 83651:20160107:132034.629 In init_trend_cache()
 83651:20160107:132034.629 In zbx_mem_required_size() size:0 chunks_num:1 descr:'trend cache' param:'TrendCacheSize'
 83651:20160107:132034.629 End of zbx_mem_required_size() size:422
 83651:20160107:132034.629 In zbx_mem_create() descr:'trend cache' param:'TrendCacheSize' size:4194304
 83651:20160107:132034.629 zbx_shmget() removing existing shm_id:1376266
 83651:20160107:132034.630 valid user addresses: [0x7f50a17a0170, 0x7f50a1b9fff0] total size: 4193920
 83651:20160107:132034.630 End of zbx_mem_create()
 83651:20160107:132034.630 End of init_trend_cache()
 83651:20160107:132034.630 End of init_database_cache()
 83651:20160107:132034.630 In init_configuration_cache() size:8388608
 83651:20160107:132034.630 In zbx_mem_create() descr:'configuration cache' param:'CacheSize' size:7130317
 83651:20160107:132034.630 zbx_shmget() removing existing shm_id:1409035
 83651:20160107:132034.630 valid user addresses: [0x7f50a10d3170, 0x7f50a179fcc0] total size: 7129936
 83651:20160107:132034.630 End of zbx_mem_create()
 83651:20160107:132034.630 In zbx_strpool_create()
 83651:20160107:132034.630 In zbx_mem_create() descr:'string pool' param:'CacheSize' size:1258291
 83651:20160107:132034.630 zbx_shmget() removing existing shm_id:1441804
 83651:20160107:132034.630 valid user addresses: [0x7f50aa55f168, 0x7f50aa692328] total size: 1257920
 83651:20160107:132034.630 End of zbx_mem_create()
 83651:20160107:132034.630 End of zbx_strpool_create()
 83651:20160107:132034.630 End of init_configuration_cache()
 83651:20160107:132034.630 In init_selfmon_collector()
 83651:20160107:132034.630 init_selfmon_collector() size:7072
 83651:20160107:132034.630 zbx_shmget() removing existing shm_id:1474573
 83651:20160107:132034.630 End of init_selfmon_collector() collector:0x7f50aa6af000
 83651:20160107:132034.630 In zbx_vc_init()
 83651:20160107:132034.630 In zbx_mem_required_size() size:0 chunks_num:1 descr:'value cache size' param:'ValueCacheSize'
 83651:20160107:132034.630 End of zbx_mem_required_size() size:427
 83651:20160107:132034.631 In zbx_mem_create() descr:'value cache size' param:'ValueCacheSize' size:8388608
 83651:20160107:132034.631 zbx_shmget() removing existing shm_id:1507342
 83651:20160107:132034.631 valid user addresses: [0x7f50a08d3170, 0x7f50a10d2ff0] total size: 8388224
 83651:20160107:132034.631 End of zbx_mem_create()
 83651:20160107:132034.631 End of zbx_vc_init()
 83651:20160107:132034.631 In zbx_db_get_database_type()
 83651:20160107:132034.631 In DBconnect() flag:0
 83651:20160107:132034.641 [Z3001] connection to database 'zabbix' failed: [0] server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

 83651:20160107:132034.641 database is down: reconnecting in 10 seconds
 83651:20160107:132044.649 [Z3001] connection to database 'zabbix' failed: [0] server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

I saw the error messages "Server closed the connection unexpectedly..." when I was using the wrong options to connect with the psql client.

  • 1
Reply Report