Skip to content
Latchkey

Gradle "Could not download" Artifact - Fix Flaky Fetches in CI

Gradle found the artifact in a repository but could not download its bytes - a read timeout or connection drop during the transfer. This is typically a transient network blip that clears on retry.

What this error means

Resolution fails with Could not download <group:name:version> and an underlying Read timed out or Connection reset. Re-running the job often succeeds with no change.

gradle output
> Could not download lib-2.3.1.jar (com.example:lib:2.3.1)
   > Could not get resource 'https://repo.maven.apache.org/.../lib-2.3.1.jar'.
      > Read timed out

Common causes

Transient timeout or reset mid-download

A slow mirror or a brief network drop times out the transfer. The artifact exists; only the download failed.

No local cache, so every jar is fetched live

Without a warm ~/.gradle/caches, CI downloads everything on each run, multiplying the chance one fetch fails.

How to fix it

Raise Gradle’s network timeouts and retry

Give downloads a longer timeout so slow mirrors do not abort, and let CI retry the step.

Terminal
./gradlew build \
  -Dorg.gradle.internal.http.connectionTimeout=60000 \
  -Dorg.gradle.internal.http.socketTimeout=60000

Cache the Gradle caches in CI

A warm cache means most artifacts are already present, so a live download failure is rare.

.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: |
      ~/.gradle/caches
      ~/.gradle/wrapper
    key: gradle-${{ hashFiles('**/*.gradle*', 'gradle/wrapper/gradle-wrapper.properties') }}

How to prevent it

  • Cache ~/.gradle/caches and ~/.gradle/wrapper in CI.
  • Raise connection/socket timeouts for slow mirrors.
  • Resolve through a pull-through mirror to reduce live downloads.

Frequently asked questions

What causes ""Could not download""?
A slow mirror or a brief network drop times out the transfer. The artifact exists; only the download failed.
How do I fix "Could not download"?
Give downloads a longer timeout so slow mirrors do not abort, and let CI retry the step.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card