Installing SonarQube Server with SQL Server

This guide provides comprehensive instructions for installing and configuring SonarQube Server with Microsoft SQL Server as the database backend.

Prerequisites

Software Requirements

  • Microsoft SQL Server: Version 2016, 2017, 2019, 2022, or 2025

    • Express Edition is supported

    • Both Windows Authentication and SQL Server Authentication are supported

  • Java: Oracle JRE or OpenJDK version 21 (Java 17 is deprecated)

  • Operating System:

    • Linux (x64, AArch64)

    • Windows (x64)

    • macOS (x64, AArch64)

Hardware Requirements

Small-Scale Installation (up to 1M lines of code)

  • RAM: 4GB minimum

  • CPU: 2 cores (64-bit system)

  • Disk Space: 30GB minimum

  • Free Disk Space: Maintain at least 10% free

Large-Scale Installation (up to 50M lines of code)

  • RAM: 16GB minimum

  • CPU: 8 cores (64-bit system)

  • Disk Space: Varies based on codebase size

  • Free Disk Space: Maintain at least 10% free

Beyond 50M lines of code

Please reach out to our commercial support teamarrow-up-right for guidance.

circle-exclamation

Database Installation and Configuration

1

Step 1: Install Microsoft SQL Server

  1. Follow the installation wizard to complete the setup

  2. Note the server name and instance name:

    • Default Instance: Uses port 1433

    • Named Instance (e.g., SQLEXPRESS): Uses dynamic ports or custom port

Enable TCP/IP Protocol (Required for SonarQube)

After installation, you must enable TCP/IP connections:

  1. Open SQL Server Configuration Manager:

    • Press Win + R and type: SQLServerManager17.msc (for SQL Server 2025), SQLServerManager16.msc (for 2022)

    • For other versions: 2022 = 16, 2019 = 15, 2017 = 14, 2016 = 13

    • Or search "SQL Server Configuration Manager" in Start Menu

  2. Enable TCP/IP Protocol:

    • Expand SQL Server Network Configuration

    • Click Protocols for [INSTANCE_NAME] (e.g., "Protocols for SQLEXPRESS")

    • Right-click TCP/IP and select Enable

  3. Configure Static Port 1433 (Optional but Recommended):

    By default, SQL Server Express uses dynamic ports. Setting a static port simplifies configuration and eliminates the need for SQL Server Browser.

    a. In SQL Server Configuration Manager, under Protocols for SQLEXPRESS:

    • Right-click TCP/IP and select Properties

    • Go to the IP Addresses tab

    • Scroll down to the IPAll section at the bottom

    b. Configure the ports:

    • TCP Dynamic Ports: Clear this field (delete any value, leave it blank)

    • TCP Port: Enter 1433

    c. Click OK

    d. You will need to restart SQL Server for changes to take effect (see Step 6 below)

circle-exclamation
  1. Enable SQL Server Browser (Critical for named instances with dynamic ports):

circle-exclamation

SQL Server Browser is often disabled by default. You must enable it:

Method A: Using Services (Recommended)

  • Press Win + R, type services.msc and press Enter

  • Scroll down and find SQL Server Browser

  • Right-click SQL Server Browser and select Properties

  • Change Startup type from Disabled to Automatic

  • Click Apply

  • Click the Start button

  • Click OK

Method B: Using SQL Server Configuration Manager

  • Go to SQL Server Services

  • Right-click SQL Server Browser and select Properties

  • Go to the Service tab

  • Set Start Mode to Automatic

  • Click OK, then right-click and select Start

  1. Enable SQL Server Authentication (Mixed Mode):

SQL Server Express defaults to Windows Authentication only. You must enable Mixed Mode for SonarQube:

  • Open SQL Server Management Studio (SSMS)

  • Connect using Windows Authentication to localhost\SQLEXPRESS

  • Right-click the server name (at top of Object Explorer)

  • Select Properties

  • Go to Security page

  • Under "Server authentication", select SQL Server and Windows Authentication mode

  • Click OK

  1. Restart SQL Server:

  • In SQL Server Services (or services.msc), right-click SQL Server (SQLEXPRESS)

  • Select Restart

circle-exclamation
2

Step 2: Connect to SQL Server Using SSMS

Connecting with SQL Server Management Studio (SSMS) 2022 / 2025

  1. Open SQL Server Management Studio (SSMS)

  2. In the "Connect to Server" dialog, enter the following:

    • Server type: Database Engine

    • Server name: localhost\SQLEXPRESS (for SQL Server Express 2022/2025)

      • Alternative formats: .\SQLEXPRESS or (local)\SQLEXPRESS

    • Authentication: Windows Authentication (default) or SQL Server Authentication

  3. Configure Certificate Trust for SQL Server 2022 / 2025

    SQL Server 2022 and 2025 enforce encryption by default but use a self-signed certificate. You'll need to trust this certificate:

    • Click Options >> at the bottom of the dialog

    • Go to the Connection Properties tab

    • Click View all SQLServer properties or look for Advanced button

    • Find and set Trust Server Certificate: True (check the box)

    Alternative method: In the Additional Connection Parameters field, add:

  4. Click Connect

circle-exclamation
3

Step 3: Create the SonarQube Database

Once connected to your SQL Server instance, execute the following steps:

  1. Create a New Database

  1. Set Database Collation

CRITICAL: Collation MUST be case-sensitive (CS) and accent-sensitive (AS).

  1. Enable READ_COMMITTED_SNAPSHOT

CRITICAL: READ_COMMITTED_SNAPSHOT MUST be enabled to prevent deadlocks under heavy loads.

Check if it's already enabled:

If the result is 0 (false), enable it:

4

Step 4: Create a SQL Server User for SonarQube

circle-info

Prerequisites: Ensure you've enabled SQL Server Authentication (Mixed Mode) in Step 1: Install Microsoft SQL Server before proceeding.

Test the SQL Server Authentication

Before configuring SonarQube, test the login in SSMS:

  1. Disconnect from SQL Server in SSMS

  2. Reconnect with:

    • Server name: localhost\SQLEXPRESS

    • Authentication: SQL Server Authentication

    • Login: sonarqube

    • Password: YourStrongPassword123!

    • Trust Server Certificate: Check this box

If the connection succeeds, proceed to SonarQube configuration.

Option B: Using Windows Authentication (Windows only)

SonarQube Server Installation

1

Step 1: Download SonarQube Server

  1. Visit the SonarQube Downloads page: https://www.sonarsource.com/products/sonarqube/downloads/

  2. Download the latest SonarQube Server Community, Developer, Enterprise, or Data Center Edition ZIP file

2

Step 2: Extract the ZIP File

Extract the downloaded ZIP file to your desired installation directory:

  • Linux/macOS: /opt/sonarqube (recommended)

  • Windows: C:\sonarqube (recommended)

Configuration

1

Step 1: Configure Database Connection

Edit the sonar.properties file located in <sonarqube_home>/conf/sonar.properties:

For SQL Server Express (Named Instance with Dynamic Port):

For SQL Server Express (Named Instance with Static Port 1433):

For SQL Server Default Instance:

For Windows Integrated Security:

SQL Server Express (Named Instance):

SQL Server Default Instance:

For Remote SQL Server:

Default Instance:

Named Instance:

2

If SQL Server doesn't support encryption:

If SQL Server requires encryption but without certificate validation:

3

Step 3: Configure Integrated Security (Windows Only)

If using Windows Authentication with Integrated Security:

  1. Download the Microsoft SQL JDBC Auth package v12.10.2: https://github.com/microsoft/mssql-jdbc/releases/download/v12.10.2/mssql-jdbc_auth.zip

  2. Extract mssql-jdbc_auth-12.10.2.x64.dll from the downloaded ZIP

  3. Copy the DLL to a folder in your system's PATH environment variable, such as:

    • C:\Windows\System32

    • Or add a custom folder to PATH

  4. Grant SQL Server Permissions to the Service Account:

    If running SonarQube as a Windows service, you must grant the service account permission to access the sonarqube database:

    a. Identify the Service Account:

    • Press Win + R, type services.msc and press Enter

    • Find the SonarQube service

    • Right-click → PropertiesLog On tab

    • Note the account name (usually Local System account, which corresponds to NT AUTHORITY\SYSTEM)

    b. Grant Permissions in SQL Server: Open SSMS and execute the following SQL (replace [NT AUTHORITY\SYSTEM] if your service uses a different account):

4

Step 4: Configure Web Server Settings (Optional)

In sonar.properties, you can customize:

5

Step 5: Configure JVM Options (Optional)

For optimal performance, you may want to adjust JVM settings in <sonarqube_home>/conf/sonar.properties:

Starting SonarQube

Linux/macOS

Windows

Using Console Mode (for troubleshooting)

Post-Installation

1

Step 1: Access the Web Interface

  1. Open a web browser and navigate to: http://localhost:9000

  2. Wait for SonarQube to fully start (this may take a few minutes on first startup)

2

Step 2: Log In with Default Credentials

  • Username: admin

  • Password: admin

circle-exclamation
3

Step 3: Configure Security Settings

After logging in:

  1. Change the default admin password

  2. Review global permissions at Administration > Security > Global Permissions

  3. Remove the Execute Analysis permission from the sonar-users group if needed

  4. Configure additional users and groups as required

4

Step 4: Install Language Plugins (if needed)

  1. Navigate to Administration > Marketplace

  2. Browse and install plugins for additional language support

  3. Restart SonarQube after installing plugins

5

Step 5: Configure Your First Project

  1. Click Create Project or navigate to Administration > Projects > Management

  2. Follow the wizard to set up your first project

  3. Generate an authentication token for analysis

  4. Configure your build tool or CI/CD pipeline

Troubleshooting

Quick Fixes for Common SQL Server Express Errors

Error: Certificate Chain Not Trusted

Error Message:

Fix: Add trustServerCertificate=true to connection string:

Error: Connection Refused on Port 1433

Error Message:

Fix Option 1: Use named instance in connection string:

Fix Option 2 (Recommended): Configure SQL Server Express to use port 1433:

  1. Open SQL Server Configuration Manager

  2. Protocols for SQLEXPRESS → Right-click TCP/IPProperties

  3. Go to IP Addresses tab → Scroll to IPAll section

  4. Clear TCP Dynamic Ports, set TCP Port to 1433

  5. Restart SQL Server service

  6. Use connection string:

Error: Connection Timeout / SQL Server Browser Not Running

Error Message:

Fix Option 1: Enable and start SQL Server Browser service:

  1. Press Win + R, type services.msc and press Enter

  2. Find SQL Server Browser

  3. Right-click → Properties → Change Startup type to Automatic

  4. Click Apply → Click Start → Click OK

  5. Restart SonarQube

Fix Option 2 (Recommended): Configure static port 1433 to avoid needing SQL Server Browser:

  1. Open SQL Server Configuration Manager

  2. Protocols for SQLEXPRESS → Right-click TCP/IPProperties

  3. Go to IP Addresses tab → Scroll to IPAll section

  4. Clear TCP Dynamic Ports, set TCP Port to 1433

  5. Restart SQL Server service

  6. Use connection string: jdbc:sqlserver://localhost:1433;databaseName=sonarqube;trustServerCertificate=true

Error: Login Failed for User

Error Message:

Fix: Enable SQL Server Authentication (Mixed Mode):

  1. Open SSMS with Windows Authentication (localhost\SQLEXPRESS)

  2. Right-click server → PropertiesSecurity

  3. Select SQL Server and Windows Authentication mode

  4. Click OK

  5. Restart SQL Server service in services.msc

  6. In SSMS, run:

Error: Login Failed for Integrated Security (Windows Only)

Error Message:

Fix: Grant permissions to the account running SonarQube (usually Local System Account):

  1. Identify the account: Usually NT AUTHORITY\SYSTEM (Local System Account)

  2. In SSMS, run:

  3. Ensure integratedSecurity=true is in the connection string and username/password are commented out.

Note: All five issues are common with SQL Server Express 2022 and 2025.

Recommended setup (simplest configuration):

  • Configure static port 1433 in SQL Server Configuration Manager (see Error 2/3 Fix Option 2)

  • Trust the certificate: trustServerCertificate=true

  • Enable Mixed Mode authentication and create the SQL login

  • Use connection string: jdbc:sqlserver://localhost:1433;databaseName=sonarqube;trustServerCertificate=true

Alternative setup (using named instance):

  • Use named instance: localhost\\SQLEXPRESS

  • Trust the certificate: trustServerCertificate=true

  • Enable SQL Server Browser service

  • Enable Mixed Mode authentication and create the SQL login

  • Use connection string: jdbc:sqlserver://localhost\\SQLEXPRESS;databaseName=sonarqube;trustServerCertificate=true

Common Issues

SonarQube Won't Start

Check the logs:

Common causes:

  • Java not installed or wrong version

  • Port 9000 already in use

  • Insufficient permissions

  • Database connection issues

Database Connection Errors

Error: "TCP/IP connection has failed" or "Connection refused"

This is the most common error, especially with SQL Server Express.

Error Messages You May See:

Or:

Solution 1: Use Named Instance in Connection String

If using SQL Server Express, specify the instance name:

Solution 2: Enable and Start SQL Server Browser

If you see error: "The connection to the host localhost, named instance sqlexpress failed" or "SocketTimeoutException: Receive timed out", the SQL Server Browser service is disabled:

  1. Press Win + R, type services.msc and press Enter

  2. Find SQL Server Browser

  3. Right-click and select Properties

  4. Change Startup type from Disabled to Automatic

  5. Click Apply

  6. Click the Start button

  7. Click OK

Solution 3: Enable TCP/IP Protocol

  1. Open SQL Server Configuration Manager

    • Press Win + R, type: SQLServerManager17.msc (SQL Server 2025), SQLServerManager16.msc (SQL Server 2022)

    • Or search "SQL Server Configuration Manager"

  2. Expand SQL Server Network Configuration

  3. Click Protocols for [INSTANCE_NAME]

  4. Right-click TCP/IP and select Enable

  5. Restart SQL Server service:

    • Go to SQL Server Services

    • Right-click SQL Server (SQLEXPRESS) and select Restart

Solution 4: Configure Static Port 1433 (Recommended Alternative)

Instead of using SQL Server Browser, configure SQL Server Express to use static port 1433:

  1. Open SQL Server Configuration Manager

  2. Go to SQL Server Network ConfigurationProtocols for SQLEXPRESS

  3. Right-click TCP/IP and select Properties

  4. Go to IP Addresses tab

  5. Scroll to bottom to IPAll section

  6. Configure:

    • TCP Dynamic Ports: Clear this field (leave blank)

    • TCP Port: Enter 1433

  7. Click OK

  8. Restart SQL Server service:

    • Go to SQL Server Services

    • Right-click SQL Server (SQLEXPRESS) and select Restart

Then use this simpler connection string:

circle-info

Benefits: No need for SQL Server Browser, simpler connection string, consistent port across environments.

Solution 5: Use Dynamic Port Connection (If Static Port Not Possible)

If you cannot set a static port, find and use the current dynamic port:

  1. Open SQL Server Configuration Manager

  2. Go to SQL Server Network ConfigurationProtocols for SQLEXPRESS

  3. Right-click TCP/IP and select Properties

  4. Go to IP Addresses tab

  5. Scroll to bottom to IPAll section

  6. Note the port number in TCP Dynamic Ports (e.g., 49172)

Then use this connection string:

Replace 49172 with your actual port number.

Solution 6: Check Firewall

  • Ensure SQL Server port is not blocked

  • For named instances with SQL Server Browser, allow UDP port 1434

  • For static port configuration, allow TCP port 1433

  • For dynamic ports, allow the specific TCP port shown in IPAll

Verify connection string:

Error: "Certificate chain was issued by an authority that is not trusted"

Error Message:

Solution: Add trustServerCertificate=true to your connection string:

This is required for SQL Server 2022 and 2025, which enforce encryption by default but use a self-signed certificate.

Error: "Login failed for user 'sonarqube'"

Error Message:

This error occurs when:

  • SQL Server Authentication (Mixed Mode) is not enabled

  • The sonarqube login doesn't exist

  • The password is incorrect

  • The user isn't mapped to the database

Solution - Step 1: Enable Mixed Mode Authentication

  1. Open SSMS and connect using Windows Authentication:

    • Server name: localhost\SQLEXPRESS

    • Authentication: Windows Authentication

  2. Enable SQL Server and Windows Authentication mode:

    • Right-click the server name (at top of Object Explorer)

    • Select Properties

    • Go to Security page

    • Under "Server authentication", select SQL Server and Windows Authentication mode

    • Click OK

  3. Restart SQL Server:

    • Press Win + R, type services.msc and press Enter

    • Find SQL Server (SQLEXPRESS)

    • Right-click and select Restart

Solution - Step 2: Create or Verify the SonarQube Login

Connect to SSMS (Windows Authentication) and run:

Solution - Step 3: Test the SQL Server Login

Before trying SonarQube again, test the login in SSMS:

  1. Disconnect from the server

  2. Reconnect with:

    • Server name: localhost\SQLEXPRESS

    • Authentication: SQL Server Authentication

    • Login: sonarqube

    • Password: YourStrongPassword123!

If the connection succeeds, your SonarQube connection will work.

Solution - Step 4: Verify sonar.properties

Ensure the password matches exactly:

Error: "Cannot open database requested by the login" (Integrated Security)

Error Message:

This error occurs with integrated security when the Windows account running the SonarQube service does not have permissions in SQL Server.

Solution - Step 1: Identify the Windows Account

  1. Press Win + R, type services.msc and press Enter.

  2. Find the SonarQube service.

  3. Right-click → PropertiesLog On tab.

  4. Note the account:

    • If it says Local System account, the user is NT AUTHORITY\SYSTEM.

    • If it says This account, it's a specific user (e.g., DOMAIN\username).

Solution - Step 2: Grant Permissions in SQL Server

Connect to SSMS (Windows Authentication) and run the following (replace [NT AUTHORITY\SYSTEM] with your account if different):

Solution - Step 3: Verify sonar.properties

Ensure integratedSecurity=true is used and credentials are removed:

Elasticsearch Won't Start

Common causes:

  • Insufficient disk space (needs at least 10% free)

  • Wrong file permissions

  • Insufficient RAM

Linux-specific prerequisites:

Performance Issues

Increase JVM heap sizes:

Use SSD storage:

  • Elasticsearch performance heavily depends on disk I/O

  • SSDs provide significantly better performance than spinning disks

READ_COMMITTED_SNAPSHOT Error

If you see deadlock errors, verify the snapshot isolation is enabled:

If it returns 0, enable it as shown in the Database Configuration section.

Database Connection Examples

SQL Server Express (Named Instance with Dynamic Port)

SQL Server Default Instance

Remote Server with Custom Port

Encryption Enabled with Trusted Certificate

Instead of storing credentials in sonar.properties, use environment variables:

circle-exclamation

Security Best Practices

Database Security

  • Use strong passwords for SQL Server accounts

  • Limit database user permissions to only what's necessary

  • Enable SQL Server encryption (TLS/SSL)

  • Keep SQL Server patched and up to date

  • Use firewall rules to restrict database access

SonarQube Security

  • Change the default admin password immediately

  • Use strong authentication mechanisms (LDAP, SAML, etc.)

  • Enable HTTPS for the web interface (use a reverse proxy)

  • Review and configure global permissions

  • Regularly update SonarQube to the latest version

  • Configure regular database backups

Network Security

  • Use a reverse proxy (NGINX, Apache) in front of SonarQube

  • Enable HTTPS with valid SSL certificates

  • Restrict access to port 9000 to trusted networks only

  • Consider using a VPN for remote access

Backup and Maintenance

Database Backup

SonarQube Data Backup

Backup the following directories:

  • <sonarqube_home>/data/ - Elasticsearch data

  • <sonarqube_home>/extensions/ - Installed plugins

  • <sonarqube_home>/conf/sonar.properties - Configuration

Updating SonarQube

  1. Backup the database and SonarQube directories

  2. Download the new version

  3. Stop the current SonarQube instance

  4. Replace the binaries (keep data, extensions, and conf folders)

  5. Start SonarQube - it will automatically upgrade the database schema

  6. Check logs for any errors

References

Microsoft SQL Server

Community Support

License

SonarQube is available as:

  • SonarQube Community Build: Open source (LGPL v3)

  • SonarQube Server Developer Edition: Commercial license

  • SonarQube Server Enterprise Edition: Commercial license

  • SonarQube Server Data Center Edition: Commercial license

See Plans and Pricingarrow-up-right for more information.

Last updated

Was this helpful?