Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unable to connect to postgres database

Zohreh Servati
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 27, 2024

We are moving are bitbucket data center  onto another host which connects to a new PostGres databae. We have replicated database and bitbucket app+bitbucket-home folders, plus other necessary setups.  However the bitbucket cannot connect to the new PostGres DB

Here is the error seen in the log:

2024-03-26 16:15:13,120 DEBUG [spring-startup] org.postgresql.Driver Connection error:
org.postgresql.util.PSQLException: Could not find a server with specified targetServerType: primary
at org.postgresql.Driver$ConnectThread.getResult(Driver.java:417)

-------------------------------------------------------

Here is the db properties set in bitbucket.properties

jdbc.driver=org.postgresql.Driver
jdbc.url=jdbc:postgresql://<hostname>.idanalytics.com:5432/<db name>
jdbc.user=<user>
jdbc.password=<passwd>

 

 

 

 

2 answers

0 votes
Rad Jandric
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 3, 2024

After some poking around I've added

host all all 0.0.0.0/0 md5

to my pg_hba.conf which allowed the connectivity from the web server (or pretty much from any host) , also check the user grants and if the bitbucket user password is correct one. Bitbucket comes with a bundled postgresql driver  already. Check the ports on which Postgres is running on something like:

netstat -tulpn | grep postgres
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 1239460/postgres
tcp6 0 0 :::5432 :::* LISTEN 1239460/postgres

Just to see if port 5432 is the one in use because during migration from lower to higher Postgres version the new cluster takes new port, like 5433 for example and config file for Bitbucket expects default 5432.

 

0 votes
Rad Jandric
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 3, 2024

I have the exact same problem, when I test the connectivity to the databsze host using command line tools it all works just fine:

bitbucket@remote-www-host: psql -h 192.168.98.11 -p 5432 -U bitbucketuser bitbucket
Password for user bitbucketuser:
psql (14.11 (Ubuntu 14.11-0ubuntu0.22.04.1), server 11.22 (Debian 11.22-0+deb10u1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

bitbucket=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+---------------+----------+-------------+-------------+-----------------------
bitbucket | bitbucketuser | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
test_db | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
test_db2 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(6 rows)

But when the app starts up I get the same error.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.21.3
TAGS
AUG Leaders

Atlassian Community Events