Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

The Gradle wrapper cannot download its distribution (services.gradle.org unreachable)

ErrorCould not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-8.x-bin.zip'.

Short answer

The wrapper must download Gradle once before it can build. It fails when the machine cannot reach services.gradle.org, when a proxy is not configured for Java, or when distributionUrl points at a version that no longer exists. Read the cause line, then fix the proxy or regenerate the wrapper.

  • Applies to Gradle wrapper 8.x and 9.x, JDK 17 and 21, Android Studio current stable, Windows 11, macOS, Linux
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open the URL from distributionUrl in a terminal. If the download starts, the network is fine and the wrapper settings are the problem.

    grep distributionUrl gradle/wrapper/gradle-wrapper.properties
    curl -I https://services.gradle.org/distributions/gradle-9.9.1-bin.zip
  2. 2Match what you see, then jump to its fix

    1. 1Unknown host services.gradle.org, while a browser on the same machine opens the pageJava has no proxy settings, but the network needs oneFix
    2. 2HTTP 403 or 404 for the URL, or a very old version such as gradle-2.1 in the filedistributionUrl points at a version or path that is wrongFix
    3. 3The failure is random, and the same URL works from curlThe connection drops during a large downloadFix

What does the error look like?

  • Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-8.x-bin.zip'.
  • Unknown host services.gradle.org. You may need to adjust the proxy settings in Gradle.
  • Server returned HTTP response code: 403 for URL

Cause 1 of 3

Java has no proxy settings, but the network needs one

1Check

The wrapper applies systemProp entries from gradle.properties, read from the project root and from the Gradle user home, as JVM system properties before it downloads.

cat ~/.gradle/gradle.properties

2Fix

Add the proxy for both http and https to gradle.properties in the Gradle user home, then list hosts that must bypass it.

systemProp.http.proxyHost=proxy.example.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.example.com
systemProp.https.proxyPort=8080
systemProp.http.nonProxyHosts=localhost|*.example.internal

3Verify

Run the wrapper again. The download starts and the version prints.

./gradlew --version

Confirmed by github.com

Did this fix it?

Cause 2 of 3

distributionUrl points at a version or path that is wrong

1Check

A copied project can carry a version that is too old for your JDK, or a hand-edited URL with a typo. Since Gradle 9.0 the file needs the full X.Y.Z version.

cat gradle/wrapper/gradle-wrapper.properties

2Fix

Regenerate the file with the wrapper task for a version your build needs. Run it twice to refresh the scripts and the wrapper jar.

./gradlew wrapper --gradle-version 9.9.1
./gradlew wrapper

3Verify

The properties file shows the new URL and the build starts.

./gradlew --version

Confirmed by docs.gradle.org

Did this fix it?

Cause 3 of 3

The connection drops during a large download

1Check

The wrapper downloads the whole zip on the first run only. A slow or unstable link can break it halfway.

curl -L -o /dev/null -w '%{speed_download}\n' https://services.gradle.org/distributions/gradle-9.9.1-bin.zip

2Fix

Ask the wrapper to retry, with a growing delay between tries.

# gradle/wrapper/gradle-wrapper.properties
retries=3
retryBackOffMs=1000

3Verify

Run the wrapper on the weak connection again.

./gradlew --version

Confirmed by docs.gradle.org

Did this fix it?

How do I stop it coming back?

  • Keep proxy settings in the Gradle user home so they follow you across projects.
  • Update the wrapper with the wrapper task instead of editing the URL by hand.
  • Cache the Gradle user home on CI so the distribution downloads once.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.