What This Error Means
Maven is running with offline mode enabled (-o / --offline), so it will not contact remote repositories to download missing artifacts.
How to Fix It
- Disable offline mode and retry the build (remove
-o/--offline). - If offline mode is set in
.mvn/maven.config, remove it (or make it conditional) and re-run the command. - If you must run offline (CI/air-gapped), pre-populate the local repository (for example by running the build once online, or by using a repository manager/cache that is reachable from the build environment).
- Retry the build after artifacts are available locally.
Why It Happens
- Offline mode was enabled intentionally (air-gapped builds, flaky networks) but required artifacts were not pre-cached.
- Offline mode was enabled unintentionally via
.mvn/maven.configor a CI template. - The local repository cache was cleared or is using a different
maven.repo.localpath than expected.
How to Verify
- Re-run the original Maven goal and confirm it can resolve dependencies without offline-mode errors.
- Confirm the previously missing artifacts now exist in
~/.m2/repository/.
Manual offline-mode checks
- Check your Maven invocation for
-o/--offline. - Check
.mvn/maven.configin the project for-o(offline mode can be enforced there). - Confirm whether the missing artifacts exist locally under
~/.m2/repository/.
Common CLI Output
[ERROR] Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.example:lib:jar:1.2.3 has not been downloaded from it before.[ERROR] Cannot access internal (https://repo.example.com/maven) in offline mode What Maven offline mode does
- In offline mode, Maven only uses the local repository cache (
~/.m2/repository). - If an artifact is missing locally, Maven cannot download it and the build fails.
- Offline mode can be enabled explicitly on the command line or implicitly via project/CI configuration.
Prevention Tips
- Use a repository manager inside the network so builds do not depend on public internet access.
- If you use offline mode in CI, ensure caches are warmed and persisted between runs.
- Document where offline mode is configured (
.mvn/maven.config, CI templates) to avoid surprises.
Where This Can Be Triggered
github.com/apache/maven/blob/maven-3.9.6/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java
Offline-mode errors are raised by the underlying resolver layer and bubbled up into Maven via the exception message (e.getMessage()). - GitHub
String msg = "Could not resolve dependencies for project " + project.getId() + ": " + e.getMessage();
DependencyResolutionException dex = new DependencyResolutionException(msg, e);
dex.setResult(e.getResult());
throw dex;