cacheport

Error · Maven

Fixing Maven "Could not transfer artifact from/to central"

Maven tried to download an artifact from Maven Central and the transfer failed part way: the connection was reset, timed out or was refused. The artifact exists; the download did not finish.

What you see

build log
[ERROR] Failed to execute goal on project app: Could not resolve dependencies for project com.acme:app:jar:1.0.0:
[ERROR] Could not transfer artifact org.springframework:spring-core:jar:6.2.0 from/to central (https://repo.maven.apache.org/maven2): Connection reset

Common causes

  • Transient network problems between the runner and Maven Central.
  • Many parallel builds downloading at once from shared addresses.
  • Proxies that cut long-running downloads.

How to fix it

  1. 01

    Retry transfers

    Maven 3.9 uses a resolver transport with configurable retries.

    .mvn/maven.config
    -Daether.connector.http.retryHandler.count=5
    -Daether.connector.requestTimeout=120000
  2. 02

    Cache the local repository

    Persist ~/.m2/repository between builds with your CI cache.

    .github/workflows/ci.yml
    - uses: actions/setup-java@v4
      with:
        distribution: temurin
        java-version: 21
        cache: maven
  3. 03

    Mirror Central through a regional cache

    One settings.xml entry routes every artifact through the cache.

    .mvn/settings.xml
    <mirror>
      <id>cacheport</id>
      <mirrorOf>*</mirrorOf>
      <url>https://acme.cacheport.cc/maven/</url>
    </mirror>

Other network failures in builds

Start on the free plan

20 GB of cache, every registry, unlimited users. Upgrade when your pipelines outgrow it.