4
votes

When I build my maven project locally, I run a sonar check. I am getting the following error. Googling hasn't resolved the issue.

I am new to SonarQube - am I missing config?

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project x: Unable to execute SonarQube: Fail to get bootstrap index from server: Failed to connect to localhost/0:0:0:0:0:0:0:1:9000: Connection refused: connect

3
have you a sonarqube instance running ? on localhost ?Maxence Lecointe

3 Answers

4
votes

The SonarQube Scanners don't run in isolation to analyze your code. They interact with a SonarQube server, and language analyzers loaded in that server.

To run an initial trial, download the latest version from sonarqube.org, expand the resulting zip, and start the server. Then you'll be able to successfully run a scan.

Note that the instructions I've just given you start the server with a for-trial-only on-board H2 database. You should not go into production with that database.

2
votes

I agree with Shiva, adding more information :

I've got into this when I tried to do sonar:sonar on my project without making sure my sonar is up & running.

Basically you should not forget to make sonar up, otherwise sonar:sonar will not find sonar listening at 9000.

If you're new to sonar, you can start sonar service from the bin folder of sonar directory sonarqube-6.7.2\bin\:

Once you're there select the appropriate folder, based on your OS & machine,

If on linux/mac : ./sonar.sh start, and if on windows : StartSonar.bat

Then you should see enter image description here

Now if you do sonar:sonar on your project, it should work by finding sonar on port 9000. I hope this might help someone out there !!

0
votes

You are trying to access sonar service which is not accessible/running, hence you are seeing this exception. Please make sure sonar service is up and running. On mac, open terminal and go to sonar installation directory path and check the sonar status by running below command,

./sonar.sh status

If server is not running, then start sonar by running below command,

./sonar.sh start

Now, open a new terminal and go to your project directory then run maven command,

mvn clean install sonar:sonar

Open your favourite browser and access sonar dashboard,

http://localhost:9000 

(By default sonar runs on port 9000)

On Sonar dashboard, you should see your project is listed, click on the project link to view the coverage.

Hope this helps.