Error "Gradle Sync Failed: Connection Refused: Connect"

Error Gradle sync failed: Connection refused: connect

You should configure Proxy settings in Android Studio’s menu (FileSettings). Another strategy is to configure the file gradle.properties.

So, add these lines at 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 other values that have special characters must have slash character such as (\#) and so on.

Android Studio 3.1.4 Gradle Sync Failed

Finally it worked!

UPDATE (Best Answer)

JCenter detects most VPNs, I have a better solution for you (Iranian developers):

There is a service that helps us to pass restrictions (like JCenter, Android Developer, and so many services): https://shecan.ir (شکن), you can use that fast service without disconnection or other headaches (it uses DNS to bypass restrictions, so usually faster than VPN).

Old Answer

Dear Iranian Developers, you can easily solve this problem with these simple steps:

1 - Turn on the Psiphon

2 - In the Psiphon (VPN) go to Settings -> Local Proxy Ports -> HTTP, HTTPS: 63620 - SOCKS: 63621. This will force the Psiphon to always use port 63620 for HTTP.

3- Go to AS Settings -> Appearance & Behavior -> System Settings -> HTTP Proxy -> Manual proxy configuration -> HTTP: Host name: 127.0.0.1 - Port: 63620 -> Uncheck Proxy Authentication.

Note: These ports (63620, 63621) are custom, but the HTTP port of the Psiphon and the AS HTTP Proxy Settings must be the same.

4 - Note: Android Studio works online only the first time you create the project. After that, you can work offline and build your project or sync it again with Gradle.

Done!

Android Studio: Gradle sync failed: Connection timed out: connect

I think it's a network issue. My project currently fails to build unless I pass the --offline argument to gradle.
I think the S3 outage is impacting repos hosting dependencies.

Try ./gradlew tasks --offline

Or, to make android studio run in offline mode, follow the instructions: https://stackoverflow.com/a/32173577/1043518



Related Topics



Leave a reply



Submit