Confluence unable to connect to PostgreSQL due to unconfigured pg_hba.conf file
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Symptoms
Unable to connect to PostgreSQL database upon the installation or startup. The following appears in the atlassian-confluence.log
:
ERROR [http-80-2] [confluence.setup.actions.AbstractSetupDatabaseAction] setupDatabase Unable to connect to database: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "10.90.8.29", user "confluenceuser", database "confluence", SSL off
-- referer: http://localhost/setup/setupstandarddb-start.action?database=postgresql | url: /setup/setupstandarddb.action | userName: anonymous | action: setupstandarddb
com.atlassian.config.bootstrap.BootstrapException: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "10.90.8.29", user "confluenceuser", database "confluence", SSL off
at com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager.getTestDatabaseConnection(DefaultAtlassianBootstrapManager.java:359)
at com.atlassian.confluence.setup.actions.SetupStandardDatabaseAction.setupDatabase(SetupStandardDatabaseAction.java:32)
at com.atlassian.confluence.setup.actions.AbstractDatabaseCreationAction.execute(AbstractDatabaseCreationAction.java:24)
...
Cause
Client authentication is controlled by a configuration file, which traditionally is named pg_hba.conf and is stored in the database cluster's data directory. For more information on postgres configuration file details:
http://www.postgresql.org/docs/9.2/static/auth-pg-hba-conf.html
Resolution
Add the IP address of the Confluence server to the pg_hba.conf
and make sure that the method is not set to reject
. You need to modify the xxx.xxx.xxx.xxx and put the IP address to allow connections.
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all xxx.xxx.xxx.xxx md5
# IPv6 local connections:
host all all ::1/128 md5
Another example, 192.168.132.17/24 where 24 is the mask which would be 255.255.255.0. If it was 255.255.0.0 then the number would be 16. For more information consult the pg_hba.conf documentation page.
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 192.168.132.17/24 trust
# IPv6 local connections:
host all all ::1/128 md5
For any changes made to the pg_hba file, please restart Postgres to pick up the change.