Reputation: 1467
So I just installed Android Studio again after a long time and it asked me to configure the proxy, so I did. I tested the connection and it worked.
Then it asked me to configure the proxy settings for Gradle and I used the same configurations.
Now, when loading the latest Vuforia Sample project, I get an error:
Gradle sync failed: Connection refused: connect
I've looked everywhere on the web, but I can't find a solution. It can't be the proxy settings; I've configured Gradle just like the IDE.
Upvotes: 47
Views: 123723
Reputation: 34471
Gradle sync failed: Connection refused: connect
When I got this error I used the Charles Proxy app (even though Charles Proxy was completely closed). To solve it, I just disabled SSL Proxying inside Charles Proxy.
After that I got
Cause: unable to find valid certification path to requested target
and
Connection refused
To solve it, just close Charles Proxy (with disabled (stopped) SSL Proxying) and restart Android Studio or analyse traffic and exclude unnecessary hosts (Proxy* -> *SSL Proxy Settings... -> Exclude
block). In my case it was
<some_digits>.cloudfront.net
Upvotes: 6
Reputation: 13633
I am writing on this old post as I have also faced the same problem after updating the Android Studio to 3.5. I was not using any proxy setting in my current project, still, it was showing me connection refused error. To resolve this problem I deleted the .android and .gradle file from User folder and restarted the android studio. It helped me to rebuild the project successfully.
Hope it will help you out.
Upvotes: 0
Reputation: 535
In my case, it was because I turned on the Wi-Fi settings, but actually my laptop Internet access using a LAN cable.
Upvotes: -1
Reputation: 47
I did the following and my problem was easily solved:
Go to menu File → Settings → Appearance & Behavior → System Settings → HTTP Proxy
On this page, select option No Proxy.
Download a VPN client.
Connect to one of the servers and sync the Gradle.
I hope your problem is solved!
Upvotes: 1
Reputation: 10688
Check and review all of these files for having proxy settings:
YOUR_PROJECT_ROOT/App/gradle.properties
~/.gradle/gradle.properties
~/.AndroidStudioX.Y/config/options/proxy.settings.xml
Note: replace X.Y
with your current Android Studio version.
Upvotes: 1
Reputation: 1
For me it worked like this:
.gradle
file. Location: C:\Users\user\.gradle
P.S. There is no proxy in my system (windows 8.1)
And it worked!
Upvotes: 0
Reputation: 6593
What works for me:
It should work now.
Upvotes: 3
Reputation: 704
In Android Studio 3.6.1 you can set the Proxy and after that, you can change that to no proxy. If still having the same issue then follow these steps:
Check the Gradle location from in Settings → Build, Execution → Deployment* → Gradle. Find the location of Gradle in your PC.
Now go to that location and open the Gradle.properties file. In this file, you have to remove the proxy settings lines.
That's it. Now your project is working.
Upvotes: 0
Reputation: 313
Amending the gradle.properties file did not work for me. What worked was manually setting the proxy in settings. Additionally, I also had to enter my user name and password for the network.
Upvotes: 0
Reputation: 4785
If you ever used Shadowsocks X-NG on Mac, (mine is version 1.7.1 (1)) and once use the Global Mode, it will automatically add the following command:
~/.gradle/gradle.propertries:
#Mon Nov 18 03:59:09 CST 2019
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyPort=1086
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1086
When you close Shadowsocks X-NG, Android studio still use the proxy, and that is why it shows
Gradle sync failed: Connection refused
Please comment those lines out, and rebuild the project again.
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Mon Nov 18 03:59:09 CST 2019
#systemProp.http.proxyHost=127.0.0.1
#systemProp.https.proxyPort=1086
#systemProp.https.proxyHost=127.0.0.1
#systemProp.http.proxyPort=1086
Upvotes: 0
Reputation: 1
I finally found the solution is to disable Avast Antivirus in my case, so if you too have an antivirus, try it or make an exception for Android Studio.
Upvotes: 0
Reputation: 783
A lot of people suggested changing proxy settings, but that was not my problem.
At the time of writing, com.android.tools.build:gradle:3.3.2
was recently released and I was not able to update to that from my network.
However, com.android.tools.build:gradle:3.3.1
was available and it no longer threw that error.
Upvotes: 0
Reputation: 1
In your gradle.properties file inside your app project, add the following properties (both HTTP and HTTPS):
systemProp.http.proxyHost=<proxyHost>
systemProp.http.proxyPort=<proxyPort>
systemProp.https.proxyHost=<proxyHost>
systemProp.https.proxyPort=<proxyPort>
If your network has a proxy (not defined in your system configuration), go to:
Menu File → Settings → Appearance & Behavior → System Settings → HTTP Proxy.
And set up Manual proxy configuration. Otherwise, check Auto-detect proxy settings.
Upvotes: 0
Reputation: 1
I find when I change the option of Preferences → Appearance & Behavior → System Settings → HTTP Proxy to Manual proxy configuration, the Gradle properties of the project won't change, so I add:
systemProp.http.proxyHost= myProxyHost
systemProp.http.proxyPort= myProxyPort
Then it runs well.
Upvotes: 0
Reputation: 1735
Go to Preferences → Appearance & Behavior → System Settings → HTTP Proxy.
If your network needs a proxy, setup Manual proxy configuration.
Else, select Auto-detect proxy settings.
Upvotes: 0
Reputation: 6983
This worked for me
commented these lines in Gradle properties
systemProp.https.proxyPort=41258 systemProp.http.proxyHost=109.199.77.83 systemProp.https.proxyHost=109.199.77.83 systemProp.http.proxyPort=41258
Use VPN
Rebuild the project
Upvotes: 3
Reputation: 1
Menu File → Settings... → Build, Execution, Deployment → Gradle → Android Studio.
Check "Enable embedded Maven repository".
Upvotes: -1
Reputation: 11
In my case, I verified that in File → Settings → HTTP proxy, I had checked the "no proxy" option.
Then I created an exception in my antivirus software for Android Studio, and deleted the lines of proxy configuration of my gradle.properties file. Finally, I clicked on Sync Project with Gradle files and it worked.
Upvotes: 1
Reputation: 201
I have the same problem:
can't connect to socks proxy connection refused
Try
Turn off VPN
Menu File → Invalidate Caches / Restart
This operation can fix this problem.
Upvotes: 16
Reputation: 45160
On a Mac, open a terminal window and hit the below command:
echo $proxy
It should return your IP address and port number.
Now check your gradle.properties of your project and set the below properties as per your login details:
systemProp.http.proxyPort=80
systemProp.http.proxyUser=<userName>
org.gradle.parallel=true
systemProp.http.proxyPassword=<PassWord>
org.gradle.jvmargs=-Xmx1536m
systemProp.https.proxyHost=<IP Address>
systemProp.http.proxyHost=<Proxy Host URL>
systemProp.https.proxyPort=<Port number form above>
Upvotes: 0
Reputation: 1472
I was caught with the same issue and was trying bypass proxies on Mac.
I removed the proxy from the system level (.bashrc) and Android Studio (gradle.properties). I had no luck!
I found Android Studio unable to bypass the proxy and finally found the proxy was cached in Gradle in the below file.
~/.gradle/gradle.properties
Essentially, to make sure proxy references were muted in all gradle.prorties, including the Gradle cache.
Gradle cache could be find as below (in Android view)
Upvotes: 41
Reputation: 4415
My case might be unique as in I got Android project code and was facing this error when trying to build it. I just removed the proxy
properties in gradle.properties
and it worked fine.
Upvotes: 2
Reputation: 167
I got the issue when I downloaded the Glide project and solved the issue by installing JDK 1.8.0_151 and reset the JAVA_HOME. My old JDK was 1.8.0_131, and I removed the old version.
Upvotes: 0
Reputation: 11
I solved my problem by putting the proxy options with http
and https
. Before it was just http
and was giving an error. After I added https
, it worked.
Upvotes: 1
Reputation: 89
This should work:
Go to 'Gradle Scripts'
Then go to 'gradle.properties'.
There you will see proxy settings something like:
systemProp.http.proxyHost=[YOUR PROXY]
systemProp.http.proxyPort=[PORT]
As you may see, this is for 'http' only.
Just add the same for 'https':
systemProp.https.proxyHost=[YOUR PROXY]
systemProp.https.proxyPort=[PORT]
It worked for me.
Upvotes: 9
Reputation: 6060
This happened to me when I updated Android Studio to the latest version.
The fix was to go to menu 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.
Upvotes: 16
Reputation: 689
Try the latest version of the Gradle build tools in build.gradle(Module:app)
Here is a screenshot:
Upvotes: 1
Reputation: 982
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.
Upvotes: 39
Reputation: 474
I had the same problem recently. I had my proxy setup OK, but Gradle could not update. After a few attempts, I noticed that the Use HTTPS proxy check button was not selected.
I noticed that on the HTTPS proxy dialog which pops up while Android Studio starts.
Keep in mind that you might not be able to see the HTTPS setup from File → Settings → HTTP Proxy, so it is important to do it using the pop-up proxy dialog on Android Studio start.
You also may have the HTTPS form filled up, but you need to select that checkbox as well (at least that worked for me).
So here are the steps I follow:
Upvotes: 9