Nexus: Error deploying artifact: Failed to transfer file: … Return code is: 401


Maven uploads work fine using the normal goal deploy:deploy, but when using deploy:deploy-file it seems like the authentication information in the settings.xml is ignored. So, it is not possible to upload to a Nexus repository, which requires password authentication for upload of artifacts.

mvn deploy:deploy-file -DpomFile=/Volumes/local/online/Programmierung/Modules/thrdArtifactDeployer/target/classes/de/mxro/thrd/artifactdeployer/artifacts/javaws.pom -Dfile=/Volumes/local/online/Programmierung/Modules/thrdArtifactDeployer/target/classes/de/mxro/thrd/artifactdeployer/artifacts/javaws.jar -DrepositoryID=thirdparty -Durl=http://yournexusserver:8080/nexus/content/repositories/thirdparty


This seems to be a bug in Maven (see bug reports below). Maybe downloading the newest version of Maven helps. (You can check your Maven version using „mvn -v“).

UPDATE 1: rmunix below has pointed out that this bug should be fixed with the Maven 3.0 release. If you are using maven embedded in eclipse, check the comments below.

UPDATE 2: Daltro has mentioned below that this still did not work for him using Maven 3.0.3. As long as you don’t add the switch “-e”

I tired using the version 2.2.0, 2.2.1 and 3.0-beta1. All of them did not work in my case. (I tired curl to upload the artifact directly and that worked …).

curl –request PUT –user username:pass http://yournexusserver:8080/nexus/content/repositories/thirdparty/com/sun/javaws/1.0/javaws-1.1.jar –data @/Volumes/local/online/Programmierung/Modules/thrdArtifactDeployer/target/classes/de/mxro/thrd/artifactdeployer/artifacts/javaws.jar –verbose

As a workaround, it is possible to upload artifacts manually using the Nexus web interface.

Here are two bug reports:
(1) HTTP 401 error upon attempting to upload artifact to thirdparty repo from command-line (For Nexus)
(2) [regression] deploy:deploy-file fails with secured repository (For Maven)

5 thoughts on “Nexus: Error deploying artifact: Failed to transfer file: … Return code is: 401

  1. Thank you for this post, I had been hitting my head against the wall because of this error when deploying with the mvn deploy:deploy-file for third party artifacts. As you pointed out it was a bug on maven, which by the way it is now fixed on the maven 3.0 release. I just tried it and it works great.



    1. Thank you! That’s good news! I’ve updated the post! It was quite a hassle to upload the artifacts manually … Will try it with Maven 3.0 (I already downloaded and installed it and so far have encountered no compatability issues with the Maven 2.0 projects)

  2. Thanks a lot for your post!!!

    I have two installations for Maven:
    -> Eclipse Embedded (3.0-SNAPSHOT/
    The deploy doesn’t work.

    -> External (2.2.1)
    The deploy works fine.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s