Gradle sonarqube scan fails with cannot connect to sonarqube error

I am testing out the sonarqube gradle feature where I am trying to run a sonarscan using gradle.
I took the steps from here https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/
I cloned the sample project, added my proxy for firewall, added sonarqube instance and sonar token, but still my scan fails with the error.

Task :sonarqube FAILED
SonarQube server [http://sonarqubehost:9000] can not be reached

I am running the task as

./gradlew -Dsonar.host.url=http://sonarqubehost:9000 -Dsonar.sonar.token=xxxxx sonarqube

My files are as follows

cat build.gradle
plugins {
id “org.sonarqube” version “3.3”
}
I also added this line in gradle.properties, just to try

systemProp.sonar.host.url=http://sonarqubehost:9000

i generated the token for admin user.
Can someone please tell me what am I doing wrong?

Hey there.

Are you sure you can access the SonarQube server from the system you’re running Gradle? A simple ‘curl’ command should tell you as much.

I had to add organisation specific proxy settings in settings.gradle file and it worked.