Unable to execute SonarScanner analysis in Command Prompt

  • Bitbucket Cloud
  • Team City
  • mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey.
  • Java

I am getting following error when execute above maven command in a Command Prompt:

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project xxxx: Unable to execute SonarScanner analysis: Fail to get bootstrap index from server: Failed to connect to localhost/ Connection refused: connect ->

I do not experience this issue for my other Projects.
Any hint what to look at.


The error itself is the best pointer:

Now the question is: why is it trying to connect to localhost/ rather than to sonarcloud.io? Among the mandatory analysis parameters is sonar.host.url, which tells analysis where to look for the server. Absent a URL value, it defaults to localhost, which is what happened here.

So you need to add -Dsonar.host.url=https://sonarcloud.io to your analysis commandline, or define the key/value pair somewhere else. Note that the SonarScanner for Maven docs list a few other parameters you’ll want to make sure are set as well.

Your other projects must have the required values set somewhere else - perhaps in their pom files.


Thanks for provided information, the root cause was that the Pom-file was overwritten so Sonar Cloud URL was no longer available…
Issues is solved.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.