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.

Fix it fast

Most likely: Maven is running with -o / --offline, but at least one required artifact is not already present in the local Maven cache.

1. Confirm this is your error
[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
2. Check the cause
cat .mvn/maven.config
mvn -version
mvn -q help:effective-settings
3. Apply the safe fix
# Remove -o / --offline from the command or .mvn/maven.config, then let Maven download what is missing.
mvn -U -DskipTests package

# If you must build offline later, warm the local repository first while online.
mvn dependency:go-offline
mvn -o -DskipTests package
4. Verify it works
mvn -DskipTests package
mvn -o -DskipTests package
Don't use unsafe shortcuts
  • Do not leave -o in .mvn/maven.config unless every build environment has a warmed cache.
  • Do not delete the local Maven cache before an offline build.
  • Do not treat this as a repository outage until you confirm offline mode is disabled.

What Offline Mode Is Blocking

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

Go back online or pre-seed the local repository

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.

Check whether the artifact is already cached locally

Check your Maven invocation for -o / --offline, check .mvn/maven.config in the project for -o (offline mode can be enforced there), and confirm whether the missing artifacts exist locally under ~/.m2/repository/.

Why Offline Mode Blocks This Build

Usually this comes down to 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, or the local repository cache was cleared or is using a different maven.repo.local path than expected.

Prove the Local Repository Has What the Build Needs

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

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.

Avoid Command and Config Drift

To prevent this, 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, and document where offline mode is configured (.mvn/maven.config, CI templates) to avoid surprises.

Docs and source code

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