Skip to main content
Announcements
Qlik Data Gateway upgrade REQUIRED by September 15 READ MORE

PostgreSQL: postgresql.conf and pg_hba.conf explained

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Andre_Sostizzo
Digital Support
Digital Support

PostgreSQL: postgresql.conf and pg_hba.conf explained

It is important to understand the options which PostgreSQL uses to allow connectivity. These principles are valid no matter whether you are using the Qlik Sense Repository Database service to host the database or using a standalone PostgreSQL instance. The two key files which PostgreSQL uses to define who can connect, how they connect, where they can connect from, and how many connections are allowed are:


For bundled PostgreSQL instances, the files are located in: 

C:\ProgramData\Qlik\Sense\Repository\PostgreSQL\x.x

If you have unbundled PostgreSQL using the Qlik PostgreSQL installer (QPI), the default location is:

C:\Program Files\PostgreSQL\xx\data

For any other standalone PostgreSQL instances, consulting with your database admin to locate the data directory. 

Note: Any changes to these files will require a restart of the Qlik Sense Repository Database or PostgreSQL.
Note: Any lines prefixed with a # are commented out and not active.

 

postgresql.conf

In the postgresql.conf, in a basic Qlik Sense configuration, there are two key configuration options which are important:

  • listen_addresses
    • This configuration defines which NICs PostgreSQL will listen on. For standalone PostgreSQL servers or multi-node Qlik Sense sites, the recommended setting is * (example below). This allows PostgreSQL to bind to any NICs presented to the server. Multiple comma-separated DNS entries may be added as well. (e.g.  listen_addresses = 'localhost,QlikServer2.domain.local' ) More advanced configurations are possible here but will not be covered in this guide.
  • max_connections
    • This configuration defines how many connections PostgreSQL will allow.  It is best to use a rule of thumb of about 110 connections per node +20.  For example, for 4 nodes set to 460. See Installing Qlik Sense in a multi node for more details. 

Where these lines are can vary but an expected single node Qlik Sense site would look like this:

listen_addresses = '*'
max_connections = 100

PostgresSQL_listen_addresses.gif

 

pg_hba.conf

The pg_hba.conf file defines a variety of aspects:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::/0                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5
host	all	            all	            0.0.0.0/0	            md5


In this example pg_hba.conf file there two active lines. The first line specifies that all users can connect to all databases from the local loopback IP using MD5 authentication (host all all 127.0.0.1/32 md5). The second line specifies that all users can connect to all databases from any valid IPv4 address using MD5 authenication (host all all 0.0.0.0/0 md5)

Please review our help for references to more sophisticated configurations where specific IP addresses or IP address ranges are covered.

To recap, when ensuring connectivity in a Qlik Sense Shared Persistence environment, especially a multi-node site, the core configurations which are needed are:

  • PostgreSQL configured to listen to an external IP address (listen_address in postgresql.conf)
  • Sufficient connections available for Qlik Sense (max_connections in postgresql.conf)
  • Explicit allowing the IP address which is used to connect (pg_hba.conf)
Labels (1)
Comments
mattias
Partner - Contributor
Partner - Contributor

What about if we have a Qlik Sense Enterprise Core with 1000 concurrent users at peak. Should I set max_connection to 1000 ?

Sonja_Bauernfeind
Digital Support
Digital Support

Hello @mattias 

The max connections setting is influenced by the number of nodes, rather than the number of concurrent users.

So: It is best to use a rule of thumb of about 110 connections per node +20.  For example, for 1 node would be 110. 4 nodes set to 460, and so on.

All the best,
Sonja 

john_oll
Partner - Creator
Partner - Creator

We just had a case von 2022-Febr (which uses PostGre 12.5  I think)
All services were running, but hub/qmc was not working (after a windows reboot),
and windows event log showed:
2022-06-09 11:44:03.130 CEST [6072] FATAL:  no pg_hba.conf entry for Host »fe80::329f:ae53:d2bd:8ead%5«, ...

Solution was:
Stop Services.
Edit the pg_hba.conf ,
It already has a line setting permissions for a different MAC-address.
So we copied that line and inserted the MAC-address from the error.
Restarted the services and everything was working again.

My best guess is that during installation the MAC-Address is put into the conf.
But if (as MIGHT have happened in this case?!) the IT changes something in the virtual network adapter of the VM, the address changes after next reboot, and Qlik Sense is no longer working, and you need to do this fix as specified.

john_oll
Partner - Creator
Partner - Creator

edit: it was a single node environment

john_oll
Partner - Creator
Partner - Creator

edit for above post: it is obviously an IPv6 address, not a MAC address.

followup:
for that customer, the IPv6 address changed again, which required redoing that fix.

Which means there is something wrong. Probably only for the PostGre 12.5 Version?!?
Again:

no pg_hba.conf entry for host


The IPv6 address of the (single node) server is hard coded (during install?) into that one file.
The IPv6 address might change. (not sure how often, not sure if custom specific causes make this more frequent)
IF it changed, the (single node) server is no longer working,
because that one line with the correct hard coded address is required for the (single node) server to keep running.
Does not sound like it is intended, so probably a BUG!?
Looking at the other lines in the file, I do not understand why this one line with the hard coded address is the only thing that determines if it works or not.

Mika_2000
Contributor III
Contributor III

Hi @john_oll,

Last week we ran into the same issue you ran into, however not for one customer but for four customers at the same time. All our customers updated and rebooted their server (see my latest post for more details).

When editing the pg_hba.conf file and allowing the IPv6 logged in the error from the event viewer we are unable to restart the Qlik Sense services. We updated Qlik Sense entirely and this did fix the issue.

Version history
Last update:
‎2023-07-25 06:37 AM
Updated by: