Installing SonarQube for Code Analysis

The steps to install SonarQube and how to host it on localhost

Samuel Hutama
Jul 27 · 3 min read

Recently, I learned that we can have our code analysed automatically by using SonarQube. It can analyse our code reliability, security, maintainability, coverage, and duplications. It covers many programming language, such as C# and Typescript, which are the ones that I use. Furthermore, it has a nice UI displaying these reports.

How to use SonarQube?

There are 2 steps which we need to do in order to analyse our code using SonarQube:

  1. Hosting SonarQube (can be hosted on localhost), and
  2. Adding our project to SonarQube to be analysed.

In this post, I will write the steps to install SonarQube and also how to host it on localhost.

Installing SonarQube

  • Download

There are multiple editions, but the free version (community edition) already gives enough features for the analysis. Here is the official link to the download page.

  • Installation (Windows)

Extract the downloaded zip file. Put it in the Windows’ drive (e.g. C:\).

  • Starting SonarQube

Go to the installed folder -> bin -> windows-x86-xx and then run “StartSonar.bat”. A command prompt will be displayed. Wait until these below lines appear:

jvm 1 | 2019.07.27 11:50:22 INFO app[][o.s.a.SchedulerImpl] Process[web] is up
jvm 1 | 2019.07.27 11:50:33 INFO app[][o.s.a.SchedulerImpl] Process[ce] is up
jvm 1 | 2019.07.27 11:50:33 INFO app[][o.s.a.SchedulerImpl] SonarQube is up

These three processes above tells us that our SonarQube is now up an running.

  • Accessing SonarQube

By default, SonarQube runs on port 9000. We only need to open our browser and navigate to “http://localhost:9000”. SonarQube will display a page that looks like below:

That’s it! Our SonarQube is up and running. As for the login credential, the default username for login is admin. The default password is also admin.

p.s. We are able to set the port in “{installation folder}\conf\sonar.properties” using the “sonar.web.port” field. We also need to make sure to remove the comment (“#”) if we do set the port.

Issues I found during installation

  • SonarQube requires Java 11+ to run

I encountered this error upon executing the “StartSonar.bat”. The cause is as clear as the error message, SonarQube requires Java 11+ to run. The solution is to download and install Java 11+ from the official site (I installed Java JDK 12). Another things to make sure is that we register the path to this Java (e.g. “C:\Program Files\Java\jdk-12.0.1\bin”) in our PATH of system environment variable.

  • cluster_block_exception [FORBIDDEN/12/index read-only / allow delete (api)]

This error also occurs when I execute “StartSonar.bat”. Turns out it happens because I don’t have enough free space left in my drive. It seems that we need to have at least 5% free space out of our drive capacity. Reference for this solution can be seen here.

Additional Notes

If “StartSonar.bat” fails to start the server and the error message doesn’t help, we can see more detailed error messages in “{installation folder}\logs\sonar.log” and “{installation folder}\logs\web.log”.


In the next post I will write about “Adding our project to SonarQube to be analysed” (Work in Progress). Once it is published, I will put the link here. Please, stay tuned! :)

Samuel Hutama

Written by

Samuel is a Full Stack Developer who is working at @PaladorTeam.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade