Error integration between sonarqube and gitlab

Hello,

With reference to below link, I trying to setup integration between sonarqube and gitlab.

I run the exact copy of the yml script as mentioned in sonarscanner cli:

sonarqube-check:
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  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:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script:
    - sonar-scanner -Dsonar.qualitygate.wait=true
  allow_failure: true
  only:
    - merge_requests
    - master
    - develop

Checked in and gitlab pipeline is triggered with error below:
ERROR: SonarQube server [http://localhost:9000] can not be reached

FYI, when I browse to http://localhost:9000, it’s actually running fine after I started the StartSonar.bat.
Also I setup the custom environment variables in gitlab too using sonarqube token and url.

Hey there.

Is SonarQube running on the same server as your Gitlab runner, or is it possibly running on your personal machine? localhost can only be accessed… locally (not by other services on other machines)

Yes both the sonarqube and gitlab runner are running in my personal machine