Your situation is described in one of two ways.
#1 You go to the SonarQube web UI to log in. You see nowhere to log in. You see this error: "Service Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later." What should you do?
Or your situation is like this:
#2 You have installed SonarQube and Apache web server. You go to the SonarQube website and the error message in the web browser is "Service Unavailable." You see some listening activity from the back-end. The Sonar service is active.
In the /var/log/httpd/ directory (the path may vary depending on how your web service is configured), the error log has entries like these:
"Connection refused: AH00957: HTTP: attempt to connect to...failed"
Why cannot you log into the web UI? Why does the web UI logon page not load correctly?
Possible Solution #1
1. Go to the back-end (the command prompt of the Linux server).
2. Go to the sonarqube directory (e.g., with conf, logs, and other subdirectories).
3. Go to logs. Look at web.log.
4. Is the sonar.properties file in the conf subdirectory configured properly? An incorrect password for the underlying SQL database could cause this problem.
Possible Solution #2
1. Find the sonar*.conf file. Use this command: sudo find / -name sonar*.conf
2. See how it refers to the server (e.g., with localhost, the hostname, the internal IP address, the loopback IP address, the external IP address). Is the reference to the server the same as the sonar.properties file for the sonar.web.host stanza? This stanza should be consistent with the httpd.conf or apache2.conf file.
3. To find the file you could run this command: sudo find / -name sonar.properties
4. Then you could run this command: cat <resultFromPreviousCommand> | grep -i sonar.web.host
5. Change the sonar.properties file so it uses the same reference to the server that the sonar*.conf file.
Possible Solution #3 (applicable if you use Apache web server with SonarQube)
1. A server reboot may be an option. If you do not do this, continue to step 2. If you do reboot the server, skip to step 3.
2. Start and stop the SonarQube service.
You may or may not do it with these two commands:
sudo systemctl sonar stop
sudo systemctl sonar start
Start and stop the Apache web server service. You may or may not do it with these two commands:
sudo systemctl httpd stop
sudo systemctl httpd start
3. Look at the /opt/sonarqube/temp/ directory. Does the subdirectory "conf" have an owner root and group root? If so, this is generally a sign of a problem.
If the "Service unavailable" problem persists look at your /etc/systemd/system/sonar.service file. Does it have these two stanzas?
The "root" for user should be changed to the user who is the owner of the /opt/sonarqube directory. The "root" for group should be changed to one of the groups for the user who is the owner of the /opt/sonarqube/ directory. To find out the groups for that user, log in as that user. Run the command "groups" to display those groups. If you need to change the owner and groups of the /opt/sonarqube directory (and subdirectories and files), run this command:
sudo chown -R sonar:sonargroup # but change sonar and sonargroup as needed.
(Remember that just because you change it once does not mean that the .../temp/conf directory will retain those changes. Cycling the Sonar services will change the ownership based on the sonar.service file's settings.)
4. After you change the sonar.service file, run this command: sudo system daemon-reload
Then restart the sonar and web services (as described in the above step 2). You should be able to get to the web UI of SonarQube. If you need to redeploy SonarQube, see this posting.