Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!

PostgreSQL: postgresql.conf and pg_hba.conf explained

100% helpful (1/1)
cancel
Showing results for 
Search instead for 
Did you mean: 
Andre_Sostizzo
Digital Support
Digital Support

PostgreSQL: postgresql.conf and pg_hba.conf explained

Last Update:

Jul 25, 2023 6:37:22 AM

Updated By:

Sonja_Bauernfeind

Created date:

Jun 4, 2018 2:03:04 PM

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 II
Partner - Contributor II

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
Partner - Contributor III
Partner - 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.

pasgalbarra
Partner - Creator
Partner - Creator

Hi @Andre_Sostizzo , @Sonja_Bauernfeind 

 

I have Qlik Sense Feb 2022 in a multinode configuration (Central node and Node1)

Last week I tried to upgrade to Feb 2023 and Postgre 12.5 using the manual upgrade and I had a problem upgrading the Node1 (the central node was fine)

I can see a SAMPLE file called pg_hba.conf and postgresql.conf in this path: (in both server)

E:\Qlik\Sense\Repository\PostgreSQL\9.6\share

Should I edit this file? in both servers?

 

Thanks

Sonja_Bauernfeind
Digital Support
Digital Support

Hello @pasgalbarra 

This article explains what these files are for and what they are used for by Qlik Sense. As we do not know what problems you ran into, it is impossible for us to recommend whether or not they should be modified and how.

If you were upgrading PostgreSQL manually (rather than with the QPI), then I assume you were following this article: How to manually upgrade the bundled Qlik Sense PostgreSQL version to 12.5 version?

What issue did you encounter?

All the best,
Sonja 

 

pasgalbarra
Partner - Creator
Partner - Creator

Hi @Sonja_Bauernfeind 

What is not clear to me is, why these files are located in a different folder than the article (share), and why these files are called .sample

pasgalbarra_0-1695718587062.png

Is this correct?

 

Thanks

Sonja_Bauernfeind
Digital Support
Digital Support

Hello @pasgalbarra 

These are not the files or the folder location you should look for. As they are also in the 9.6 folder and you mentioned you had updated to 12.x, this folder would not be used. It being installed in a different location (shared) would also indicate that this was customised or renamed at some point.

Without knowing what steps you followed to upgrade in detail, as well as where it failed and what errors you received, it is difficult to give you advice on this. But these files (.samples) are, from what I understand, "blank" samples Postgres drops in before the database is in use. Qlik Sense would, in this case, not be looking at them.

Reviewing the timestamps on them also reveals that they were created and last modified in 2022.

The files you are looking for are going to be in the location documented in this article (if everything was installed with default settings).

All the best,
Sonja 

 

 

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