What This Error Means
Maven attempted to download an artifact or metadata from a repository, but the HTTP(S) transfer failed.
How to Fix It
- Identify the exact repository host and URL Maven is trying to reach (copy it from the error line).
- If you are behind a corporate proxy, configure it in
~/.m2/settings.xmlunder<proxies>and re-run the build. - If the error is TLS-related, fix certificate trust for the JDK running Maven (import the corporate/root CA), then retry.
- Force Maven to retry metadata/artifacts once:
mvn -U -DskipTests package. - If your repository is self-hosted, check repository health (HTTP status, storage, TLS cert validity) and try again.
- Re-run with debug logs if you still can't see the root cause:
mvn -X -DskipTests package.
Why It Happens
- The repository host is down or temporarily unreachable.
- A firewall/VPN/proxy blocks Maven from reaching the repository (or performs TLS interception without a trusted CA).
- DNS resolution fails for the repository hostname.
- The connection is being reset or timing out (unstable network, packet loss, overloaded proxy).
- Maven is running in offline mode (
-o) and cannot refresh missing artifacts.
How to Verify
- Re-run the original Maven goal and confirm artifacts/metadata are downloaded successfully.
- Confirm the artifact now exists in the local repository under
~/.m2/repository/.
Manual network and repository checks
- Copy the repository URL from the error output and test basic reachability (DNS + TCP + TLS).
- Check whether Maven is configured with a proxy:
mvn -q help:effective-settings(look for<proxies>). - Run once with full debug output to see the exact URLs and transports being used:
mvn -X -DskipTests package. - If the failure is intermittent, retry the same build on a stable network and compare results.
Common CLI Output
[ERROR] Could not transfer artifact org.example:lib:jar:1.2.3 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/example/lib/1.2.3/lib-1.2.3.jar[ERROR] Could not transfer metadata org.example:lib/maven-metadata.xml from/to internal (https://repo.example.com/maven): transfer failed for https://repo.example.com/maven/org/example/lib/maven-metadata.xml How Maven downloads artifacts
- Maven downloads artifacts (and metadata like
maven-metadata.xml) over HTTP(S) from your configured repositories. - Network errors, proxies, TLS inspection, DNS failures, or repository outages can cause transfers to fail even when coordinates are correct.
Prevention Tips
- Use a local repository manager proxy to reduce network dependency on upstream repositories.
- Keep proxy and mirror configuration consistent across developer and CI environments.
- Avoid mixing multiple repository URLs across projects, prefer one mirrored endpoint.
Where This Can Be Triggered
github.com/apache/maven/blob/maven-3.9.11/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7128BlockExternalHttpReactorTest.java
Maven's integration tests assert the exact "Could not transfer artifact ..." output when an HTTP repository is blocked (MNG-7128). - GitHub
verifier.verifyTextInLog( "[ERROR] Failed to execute goal on project http-repository-in-pom: "
+ "Could not resolve dependencies for project org.apache.maven.its.mng7128:http-repository-in-pom:jar:1.0: "
+ "Failed to collect dependencies at junit:junit:jar:1.3: "
+ "Failed to read artifact descriptor for junit:junit:jar:1.3: "
+ "Could not transfer artifact junit:junit:pom:1.3 from/to maven-default-http-blocker (http://0.0.0.0/): "
+ "Blocked mirror for repositories: [insecure-http-repo (http://repo.maven.apache.org/, default, releases+snapshots)]" );