Exception in thread "main" java.net.UnknownHostException: services.gradle.org
Solution 1
Go to "C:\Users\[yourusername]\.gradle\" folder (hidden folder - Go to folder option and enable show hidden files if folder is not showing up)
Look for file "gradle.properties" if DOES NOT (most likely this would be the case) exists, Create it under "C:\Users\[yourusername]\.gradle\
Copy and paste following code (More detail ... https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties ... look for "20.3 Accessing the web via proxy" for https and user/pwd variables)
systemProp.http.proxyHost=[PROXY SERVER] systemProp.http.proxyPort=[PROXY PORT]
- save and try again
Solution 2
look for gradle.properties file open it and change from 'distributionUrl=https\' to 'distributionUrl=http\' that will fix it.
Solution 3
I was facing the same problem when I was connected to WiFi with a download speed of 80 Mbps which is good enough, I guess. After spending hours while still being clueless, I just changed the network. Connected to hotspot from my mobile data with a much lower download speed of around 4 Mbps. The error vanished! Maybe something was wrong with the WiFi.
Solution 4
1) Go to your project directory
2) Find below file on your project directory:
gradlew
gradlew.bat
3) Edit gradlew file and change DEFAULT_JVM_OPTS variable value as below:
DEFAULT_JVM_OPTS="-Dhttp.proxyHost=XXXX -Dhttp.proxyPort=XXXX -Dhttp.proxyUser=XXXX -Dhttp.proxyPassword=XXXX -Dhttps.proxyHost=XXXX -Dhttps.proxyPort=XXXX -Dhttps.proxyUser=XXXX-Dhttps.proxyPassword=XXXX"
save it.
4) Edit gradlew.bat file and change DEFAULT_JVM_OPTS variable value as below:
set DEFAULT_JVM_OPTS=-Dhttp.proxyHost=XXXX -Dhttp.proxyPort=XXXX -Dhttp.proxyUser=XXXX -Dhttp.proxyPassword=XXXX -Dhttps.proxyHost=XXXX -Dhttps.proxyPort=XXXX -Dhttps.proxyUser=XXXX-Dhttps.proxyPassword=XXXX
save it.
5) Now run your "gradlew clean build" and check.
Please set your appropriate value on the place of XXXX
Note: gradlew is use for linux system user and gradlew.bat is user for window system user
Solution 5
Make sure you have enough bandwidth for the download.
I had the same problem just 15 minutes ago (that's why I'm on this page in the first place). Same error message --- and then I noticed that my uTorrent client was occupying the whole datalink. So I killed it, and run gradlew.bat
again. This time everything went just fine...
geetha
Updated on August 03, 2022Comments
-
geetha almost 2 years
I am getting the below error when executing
gradle.bat
. I have checked the URL path and it looks fine. The URL is defined like this in the wrapper properties:distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip
Here's the error message:
Downloading https://services.gradle.org/distributions/gradle-2.1-bin.zip Exception in thread "main" java.net.UnknownHostException: services.gradle.org at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
Could someone help me on this?
-
MirandaVeracruzDeLaHoyaCardina almost 8 yearsThanks, this helped me. I just had to add a section for systemProp.https.proxyHost= systemProp.https.proxyPort=
-
pradeep almost 7 yearsI tried what you gave. Now gradle is downloaded but something other error is came
-
pradeep almost 7 yearsA problem occurred configuring root project 'pmdemo'. > Could not resolve all dependencies for configuration ':classpath'. > Could not resolve com.android.tools.build:gradle:1.3.1. Required by: :pmdemo:unspecified > Could not resolve com.android.tools.build:gradle:1.3.1. > Could not get resource 'jcenter.bintray.com/com/android/tools /build/gradle/1.3.1/gradle-1.3.1.pom'. > Could not GET 'jcenter.bintray.com/com/android/tools/build /gradle/1.3.1/gradle-1.3.1.pom'. Received status code 403 from server: Forbidden
-
mLstudent33 almost 3 yearsCould this happen if WiFi is sporadic during
flutter create myapp
?