Error Gradle sync failed: Connection refused: connect
You should configure Proxy settings in Android Studio’s menu (File → Settings). 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
Navigate from One Fragment to Another on Click of a Button
Android: Mkdirs()/Mkdir() on External Storage Returns False
How to Set Android_Ndk_Home So That Android Studio Does Not Ask for Ndk Location
How to Scroll Scrollview to Bottom Programmatically in Android
Where Is Android_Sdk_Root and How to Set It.
How to Capitalize the First Letter of Text in a Textview in an Android Application
How to Get Last Record from Sqlite
Android Check Null or Empty String in Android
App Crashes (Sometimes) With Fatal Signal 11 (Sigsegv), Code 1
How to Refresh a Previous Activity After the Back Button Is Pressed
How to Remove Focus from Edittext When User Is Done Editing
How to Quit Android Application Programmatically
How to Set Space Between Listview Items in Android
How to Remove Android Auto-Suggest Underlining in Edittext
Access Ro.Serialno from Native in Android 8
How to Turn a Portable Sd Card into Internal Storage Via Adb Command