GitLab Runner Unable to Connect to SonarQube Server results SonarQube Server can not be reached

I am trying to configure SAST through SonarQube and have added the required pipeline configuration, but the GitLab Runner is throwing an error saying, “SonarQube Server is unable to connect.”

SonarQube is running on AWS ECS. I have reviewed all inbound and outbound traffic rules in the security group and NACL, and they are configured correctly. The SonarQube token and host configuration URL are also set up correctly.

Do you have any suggestions on how to resolve this connectivity issue with the GitLab Runner to run SAST successfully?

Error details:

.gitlab-ci.yml Configuration

  stage: test 
  only:
    refs:
      - dev  
  # dependencies:
  #   # - get-binaries
  #   - build 
  image: maven:3-eclipse-temurin-17
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
    GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task
  cache:
    policy: pull
    key: "${CI_COMMIT_SHORT_SHA}"
    paths:
      - sonar-scanner/
  script: 
    - mvn verify sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_TOKEN

  interruptible: true
  allow_failure: true

Versions

Gitlab Versions:

GitLab.com SaaS
image

I know I am not solving your sonarqube setting issue… but this might be a workaround but looking at the problem in a different way. Check out sonarless

It avoid the need to setup a centralized hosted sonarqube but enabling extreme automation of personal sonarqube that even works inside gitlab containers.