What This Error Means
Maven is using an HTTP proxy to reach repositories, but the proxy requires authentication and Maven is not configured with valid proxy credentials.
How to Fix It
- Add or update a
<proxy>entry in~/.m2/settings.xmlwith the correct host, port, protocol, and credentials. - If only one proxy should be active, ensure only one
<proxy>has<active>true</active>. - If you have an internal repository manager, add its host to
nonProxyHostsso Maven can reach it directly. - Re-run the Maven command. If it still fails, run with debug logs:
mvn -X -DskipTests packageand confirm the proxy settings being used.
Why It Happens
- Proxy configuration is missing from
settings.xmlon the machine running Maven. - Proxy username/password is missing or incorrect.
- The proxy changed (host/port) or credentials were rotated.
- Maven is unintentionally using a proxy in one environment but not another (different settings files).
How to Verify
- Re-run the original Maven goal and confirm Maven can download artifacts without 407 responses.
- Confirm at least one new artifact is written to
~/.m2/repository/.
Manual proxy configuration checks
- Print effective settings and check
<proxies>:mvn -q help:effective-settings. - Confirm the proxy
host,port, andprotocolmatch your network requirements (HTTP vs HTTPS proxy). - Confirm
nonProxyHostsincludes internal repository hosts that should bypass the proxy (if applicable). - Retry with debug logs to confirm Maven is attempting to use the proxy:
mvn -X -DskipTests package.
Common CLI Output
[ERROR] Failed to transfer file: https://repo.maven.apache.org/maven2/... Return code is: 407, ReasonPhrase: Proxy Authentication Required.[ERROR] 407 Proxy Authentication Required How Maven uses proxies
- Maven proxy settings live in
~/.m2/settings.xmlunder<proxies>. - If a proxy is required for outbound traffic, Maven must be configured with the correct proxy host/port and (if needed) username/password.
- If proxy auth is missing or wrong, the proxy responds with 407 and Maven cannot reach repositories.
Prevention Tips
- Standardize
settings.xmldistribution for developers and CI so proxy configuration is consistent. - Use a repository manager inside the network so external proxy rules affect fewer endpoints.
- Document required proxy settings (including
nonProxyHosts) for build environments.
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
HTTP proxy failures (407) are surfaced to Maven as a transfer failure message from the underlying resolver/wagon layer (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;