Unable to connect sonarqube db " port 5432 failed: server closed the connection unexpectedly"

I’m able to connect the sonarqube db which has been created locally but when i’m trying to connect remote facing the below error. Please help me to fix the below error.

C:\sonarqube>psql “sslmode=verify-full sslrootcert=BaltimoreCyberTrustRoot.crt.pem host=us6-corp-platforms-sonarqube-db-dev.postgres.database.azure.com dbname=sonaqube-devtest-db user=sonarqube@us6-corp-platforms-sonarqube-db-dev”
Password for user sonarqube@us6-corp-platforms-sonarqube-db-dev:
psql: error: connection to server at “us6-corp-platforms-sonarqube-db-dev.postgres.database.azure.com” (40.70.144.38), port 5432 failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

Steps followed:

  1. Downloaded cert from https://www.digicert.com/CACerts/BaltimoreCyberTrustRoot.crt.pem.
  2. Saved in my c:drive → C:\sonarqube\BaltimoreCyberTrustRoot.crt.pem
  3. Set the path in command prompt where cert has been saved in my local system.
  4. Changes modified to the command accordingly: C:\sonarqube>psql "sslmode=verify-full sslrootcert=BaltimoreCyberTrustRoot.crt.pem host=us6-corp-platforms-sonarqube-db-dev.postgres.database.azure.com dbname=sonaqube-devtest-db user=sonarqube@us6-corp-platforms-sonarqube-db-dev"
    Asked the the password: entered correctly and returned with below error.

Password for user sonarqube@us6-corp-platforms-sonarqube-db-dev:
psql: error: connection to server at “us6-corp-platforms-sonarqube-db-dev.postgres.database.azure.com” (40.70.144.38), port 5432 failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

Hey there.

It looks like you’re facing an issue running psql commands (simply connecting to the database from your local machine), not actually connecting to the database using SonarQube.

We can help with the latter, but first you’ll need to sort out connectivity between your machine and the database, which is a networking issue (not a SonarQube issue).

Sure, I’m trying to fix it. I have whitelisted my system public IP in database server but still same issue.

I’m able to connect both source & target databases from my local machine…
I Would need your assistance on how to configure sonarqube jar file to migrate the data from source to target database. I’m accessing sonarqube for the first time and have gone through sonarqube db copy tool documention but still have questions how to configure sonarqube jar file. Could you please assist me about the process of database migration using SonarQube DB Copy Tool.

Note: Source and target databases are PSQL and version is 14.3

Hi Team,

I have gone through the sonarqube db copy tool docs and have couple of questions while executing the jar file.

  1. In the DB copy preparation phase, there’s a point stating that “Configure your SonarQube copy to connect to the target database. (If you’ve placed your SonarQube copy on the same server that runs your primary SonarQube instance, you’ll also need to configure non-default ports for your copy SonarQube instance.)

Which means do i need to take a copy of primary sonarqube database and connect to the target database?

  1. How to pass below parameters in the jar file?

driverSrc : null
urlSrc : null
userSrc : null
pwdSrc : null
urlDest : null
driverDest : null
userDest : null
pwdDest : null
commitSize : 5000

Thanks,
Jagan Siram