Gradle sync failed: Connection refused

You should configure Proxy settings on Android Studios menu (File | Settings). Another strategy is to configure the file gradle.properties.

So, add theses lines for the end of gradle.properties located on the app folder base.


systemProp.http.proxyPassword=[PASSWORD]
systemProp.http.proxyHost=[IP ADDRESS]
systemProp.https.proxyPort=[PORT, TYPICALLY 3128]
systemProp.https.proxyUser=[USERNAME]
systemProp.https.proxyHost=[IP ADDRESS]
systemProp.https.proxyPassword=[PASSWORD]
systemProp.http.proxyPort=[PORT, TYPICALLY 3128]
systemProp.http.proxyUser=[USERNAME]

Pay attention, the passwords and others values that have special chars must have slash character such as (\#) and so on.


I caught with same issue and was trying bypass proxies in Mac. Removed proxy from system-level(bashrc) and studio(gradle.properties). had no luck!

Found the studio unable to bypass the proxy, finally found the proxy was cahced in gradle in below file.

~/.gradle/gradle.properties

Essentially to make sure proxy referenes were muted in all gradle.prorties, inlcuding gradle cache.

gradle cache could be find as below(in Android view)


This happened to me when I updated Android Studio to the latest version.

The fix was to go to File/Settings/Build Execution Deployment/Gradle and check Use local gradle distribution

After that, in Gradle Home put the location to the gradle directory - in my case it was C:\Program Files\Android\Android Studio\gradle\gradle-3.2

enter image description here