Error Knowledge Base MAVEN OFFLINE_MODE

Cannot access <repository> in offline mode

Maven is running with offline mode enabled (`-o` / `--offline`), so it will not contact remote repositories to download missing artifacts.

Affected versions: All supported Apache Maven versions.

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

  1. Disable offline mode and retry the build (remove -o / --offline).
  2. If offline mode is set in .mvn/maven.config, remove it (or make it conditional) and re-run the command.
  3. 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).
  4. 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.config or a CI template.
  • The local repository cache was cleared or is using a different maven.repo.local path than expected.

How to Verify

  1. Re-run the original Maven goal and confirm it can resolve dependencies without offline-mode errors.
  2. Confirm the previously missing artifacts now exist in ~/.m2/repository/.

Manual offline-mode checks

  1. Check your Maven invocation for -o / --offline.
  2. Check .mvn/maven.config in the project for -o (offline mode can be enforced there).
  3. 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

  1. In offline mode, Maven only uses the local repository cache (~/.m2/repository).
  2. If an artifact is missing locally, Maven cannot download it and the build fails.
  3. 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;

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list