Bitbucket is unable to connect to PostgreSQL due to unconfigured pg_hba.conf file

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs 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

Problem

Scenario #1:

When starting Bitbucket Service, the following is shown on the browser:

(Auto-migrated image: description temporarily unavailable)

Scenario #2:

The following appears in the atlassian-bitbucket.log

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 The configuration entered is not valid. A database connection could not be established. Please check your configuration and try again. Hide details The configuration entered is not valid. A database connection could not be established. Please check your configuration and try again. com.atlassian.stash.internal.db.DefaultDatabaseManager.validateConfiguration(DefaultDatabaseManager.java:217) com.atlassian.stash.internal.migration.DefaultMigrationService.validateConfiguration(DefaultMigrationService.java:85) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ... Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "192.168.10.5", user "stashdbuser", database "stashdb", SSL off org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) com.atlassian.stash.internal.db.DefaultDatabaseValidator.validate(DefaultDatabaseValidator.java:44) com.atlassian.stash.internal.db.DefaultDatabaseManager.validateConfiguration(DefaultDatabaseManager.java:214) ... FATAL: no pg_hba.conf entry for host "192.168.10.5", user "stashdbuser", database "stashdb", SSL off org.postgresql.Driver$ConnectThread.getResult(Driver.java:358) org.postgresql.Driver.connect(Driver.java:282) java.sql.DriverManager.getConnection(DriverManager.java:664)

Cause

PostgreSQL has a list of allowed IP (configured in pg_hba.conf) that allow access to the database server. There is a missing entry for the host. 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 Bitbucket 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. Edit the [pg_hba.conf|https://www.postgresql.org/docs/devel/auth-pg-hba-conf.html] file and add an entry to the Bitbucket server IP:

1 2 3 4 5 6 7 # 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
Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.