How Do You Get the sonar.sh Console to Actually Work When the Screen Says That “SonarQube is already running”?

Problem scenario
You stop SonarQube services from running.  You want to log into the web UI console to set things up.  You run this command:

sudo bash /opt/sonarqube/bin/linux-x86-64/sonar.sh console

But all you see is


Running SonarQube…
SonarQube is already running.

You never get a network service to listen on port 9000.  How do you use “sonar.sh console” to initially configure Sonar?

How Do You Troubleshoot the SonarQube Service Not Working with a “vendor preset: disabled” Error?

Problem scenario
The SonarQube service failed to start.  

You see this message:

? sonar.service – SonarQube service
   Loaded: loaded (/etc/systemd/system/sonar.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Mon 2018-05-21 14:34:34 UTC; 12min ago

May 21 14:34:33 sonarserver systemd[1]: Started SonarQube service.
May 21 14:34:34 sonarserver systemd[1]: sonar.service holdoff time over, scheduling restart.
May 21 14:34:34 sonarserver systemd[1]: start request repeated too quickly for sonar.service
May 21 14:34:34 sonarserver systemd[1]: Failed to start SonarQube service.

How Do You Troubleshoot the SonarQube Scanner Error “java.lang.IllegalStateException: Unable to load component class or.sonar.scanner.scan.ProjectLock”?

Problem scenario
You are trying to run SonarScanner, but you get an error about “java.lang.IllegalStateException: Unable to load component class or.sonar.scanner.scan.ProjectLock”.  What should you do?

Possible solution
Is there a sonar-project.properties file in the directory where you are running the above command?  Does your user have access to read the file?  Check these things first.

How Do You Troubleshoot a “500 Error” with SonarQube?

Problem scenario
You try to run SonarScanner or do something with SonarQube.  You get a “500 Error” or some related internal server error.  What should you do?

Solution
Reinstall Java.  It is a dependency for SonarQube.  You can keep SonarQube installed and just stop the services while you uninstall and reinstall Java.  After you remove Java (and do research if you don’t know how), you can use this 

How Do You Troubleshoot “Failed to start sonar.service: Unit not found” Error?

Problem scenario
You run “sudo systemctl start sonar”, but you get this message: “Failed to start sonar.service: Unit not found”

What should you do?

Solution
Run this: sudo systemctl enable sonar

Now you should be able to run your command to start the “sonar” service.

How Do You Access the SonarQube Web UI When It Is Only Listening on the 127.0.0.1 IP Address?

Problem scenario
SonarQube is listening on the loopback IP address on port 9000.  SonarQube is not listening on the external IP address.   You want to access the web UI for SonarQube. What should you do?

Solution
Install a web server and configure it to connect to port 9000.  Here are the details for using Apache web server on a Red Hat derivative (e.g., CentOS/RHEL/Fedora).

1. 

How Do You Troubleshoot SonarQube Not Working when the Logs Have a Comment about Not Being Able to Connect to the Database?

Problem scenario
In the SonarQube logs you get an error “java.lang.IllegalStateException: Can not connect to database.  Please check connectivity and settings (see the properties prefixed by ‘sonar.jdbc’)”

How do you troubleshoot this error?

Solution
1.  Verify you can ping the hostname.  

2.  Test the port with nmap (e.g., “nmap -p 1521 <databaseFQDN>” where <databaseFQDN> is the hostname of the database and 1521 is the port you configured in the stanza with “sonar.jdbc”). 

What Do You Do If SonarQube Has No Logs and the Service Will Not Start?

Problem scenario
You try to start the SonarQube service.  It does not turn on or stay on.  You go to the logs directory in the “sonar” subdirectory on the Linux server.  Every time you run “sudo systemctl start sonar”, there are no corresponding log entries.  You may find no logs at all.  What should you do to troubleshoot SonarQube to start when the logs are not helping you?

Solution
1. 

How Do You Troubleshoot SonarQube Not Starting Correctly and ce.Log Not Being Created Properly?

Problem scenario
You are running SonarQube.  The service seems to start (based on the output of “sudo systemctl status sonar”).  But based on an nmap command on your server’s external IP address, you see no service is listening.  You go to the logs directory and cannot find the ce.log file.  You cannot reach the web UI for SonarQube.  How do you fix this problem?

Possible Solution #1
Look at your sonar.properties file. 

How Do You Get the SonarQube Service to Remain on when It Stops Shortly after Being Started?

Problem scenario
You start SonarQube and the service seems to come up.  You see TCP port connection activity.  It does not stay up long enough to log in.  

You have SonarQube installed on a Linux server.  SonarQube starts, but it does not remain running because it dies out.  It stops running after 30 seconds of being started.  

In /opt/sonarqube/es.log you see a message like this: