Confluence unable to connect to PostgreSQL due to unconfigured pg_hba.conf file

Still need help?

The Atlassian Community is here for you.

Ask the community

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

(info) For any changes made to the pg_hba file, please restart Postgres to pick up the change.


Last modified on Jul 22, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.