Database Migration from Postgres database to sql database

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    We are using SonarQube Version: 9.0.0-enterprise
  • how is SonarQube deployed: zip, Docker, Helm
    We are deploying the Postgres DB, nginx-ingress and SonarQube using helm chart.
  • what are you trying to achieve
    I have an external MS Sql db created in another resource group and I am trying to copy/ migrate the data from Postgres db which is inside the AKS cluster to MS Sql DB which is outside the AKS.

I have installed DB copy tool, I am trying to use below command to migrate data
*java -jar sonar-db-copy- -urlSrc jdbc:postgresql:// -userSrc sonarUserNew -pwdSrc **** -urlDest 'jdbc:sqlserver://;database=sonarnewDB' -userDest sonarUserNew -pwdDest *****

I am getting the below error that cant reach to postgres DB even if I give the correct url,

Exception in thread "main" com.sonar.dbcopy.utils.toolconfig.SqlDbCopyException: Database can not be reached at url jdbc:postgresql://sonarqube-postgresql:5432/sonarDB. Verify url, user name and password.
        at com.sonar.dbcopy.prepare.ConnectionVerifier.databaseIsReached(
        at com.sonar.dbcopy.StartApp.main(
Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(
        at org.postgresql.core.ConnectionFactory.openConnection(
        at org.postgresql.jdbc.PgConnection.<init>(
        at org.postgresql.Driver.makeConnection(
        at org.postgresql.Driver.connect(
        at java.sql/java.sql.DriverManager.getConnection(
        at java.sql/java.sql.DriverManager.getConnection(
        at com.sonar.dbcopy.prepare.ConnectionVerifier.databaseIsReached(
        ... 1 more
Caused by: sonarqube-postgresql
        at java.base/
        at java.base/
        at java.base/
        at org.postgresql.core.PGStream.createSocket(
        at org.postgresql.core.PGStream.<init>(
        at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(
        ... 8 more
NAME                                                  READY   STATUS    RESTARTS         AGE
sonarqube-ingress-nginx-controller-67fb67b5c9-rvdlj   1/1     Running   0                9d
sonarqube-postgresql-0                                1/1     Running   0                26d
sonarqube-sonarqube-0                                 1/1     Running   11 (7d21h ago)   26d

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!


Here’s the error

It’s interesting to me that the DB host in the error messages, sonarqube-postgresql doesn’t match what’s in your command,, but I assume that’s about obfuscation/redaction for publication. If it’s not, then I suppose that points to a DNS problem.


Hi Ann Cambell

I have tried using sonarqube-postgresql aswell, I was getting the same issue.


I don’t know what else to tell you. You need to sort out why your SonarQube instance can’t talk to your DB.


Sorry to confuse you, I am trying to migrate the Database from Postgres Sql to MS Sql Server. In this process I am following a sonarqube documentation to migrate the our Database : SonarQube database copy tool
When I execute the DB copy command, I am getting the above error stating that command could not reach to Postgres Sql DB.


Sorry about the confusion. I didn’t read all the way from the top again.

But the answer is still the same: you need to sort out why SonarQube the process can’t connect to your DB.