31

My NuGet server is throwing a 405 Not Allowed when I try to make a push. At least, thats what NuGet console says:

Failed to process request. 'Method Not Allowed'.
The remote server returned an error: (405) Method Not Allowed..

But when I look at the actual HTTP response with Fiddler the problem seems to be totally different:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code></code>
  <message xml:lang="en-US">The URL representing the root of the service only supports GET requests.</message>
</error>

Any ideas on what might be going on?

Thanks!

tucaz
  • 6,524
  • 6
  • 37
  • 60
  • If you get here and are looking at this issue make sure you do as the OP has and check the HTTP response, not all 405s are the same and NuGet doesn't give you the full detail. – Liam Dec 07 '17 at 14:19

8 Answers8

56

After a few hours working on the issue I was able to find the problem.

When you LIST packages in NuGet server you point to http://nugetserver.com/nuget. However when you are trying to PUSH or DELETE a package you need to point to http://nugetserver.com without the nuget folder in the path.

What happens is that NuGet.exe append /api/v2/package to the URL turning it into http://nugetserver.com/api/v2/package

I think this is far from optimal because it makes you add two different sources to your nuget.exe.config: one for the get/list and another for pushing/deleting packages.

tucaz
  • 6,524
  • 6
  • 37
  • 60
  • I am hosting the feed in my local dev server. If I just use the url without /nuget it throws error: 404 (Not Found) . I have done all from removing webdev, adding permission etc but still gives me error. – aman Jan 24 '18 at 19:54
  • Has this changed? I just updated an old NuGet Server and now it fails unless the extra `/nuget` is added to the push source as well. (Before the update the extra `/nuget` was not allowed to be in the push source.) – Peter Feb 05 '18 at 10:28
54

In addition to using nuget push -Source http://nugetserver.com, I did this:

<!--Add the following to the beginning of <system.webServer><modules>:-->
<remove name="WebDAVModule" />
<!--Add the following to the beginning of <system.webServer><handlers>:-->
<remove name="WebDAV" />

Source: Nuget issue #1789

Liam
  • 27,717
  • 28
  • 128
  • 190
Kevin Smyth
  • 1,892
  • 21
  • 22
4

I had the same error - in my case, my NuGet environment variable was pointing to an old v2 version of NuGet, and I was trying to push to a v3 feed.

Repointing my environment variable to a v3 NuGet.exe fixed it.

Silly error, but hopefully that might save someone some time.

booler
  • 705
  • 1
  • 7
  • 15
1

the solution for me - running a local IIS on a Win 8.1 computer -
was to enable "Windows authentication" and "ASP.NET Impersonation"

oakman
  • 297
  • 1
  • 8
0

The fix for me was in IIS. I disabled windows authentication and enabled anonymous authentication.

I was pushing to my own nuget server.

theUser
  • 1,346
  • 3
  • 21
  • 40
0

I'm running version 3.1.2. After battling with this problem for a while, the following did it for me:

  • Give write permissions to the Packages folder on the server
  • Because I had deleted the previous packages in the Packages folder, I also had to delete the '*.cache.bin' file in the Packages folder.
  • Ran command as "nuget.exe push {package file} {apikey} -Source {ipaddress:port}/nuget" Note the "/nuget" at the end.
0

Solution for me was to use latest Nuget.exe [3.5.0], for some strange reason I had old NuGet.exe (2.8.5 [2017 version]) which was failing with 405 error. Hope this helps someone.

Mahesh Nayak
  • 208
  • 4
  • 14
0

If you have IIS 8.0, WebDAV publishing method doesn't allow nuget Push. Uninstall it from IIS and things would work WebDAV uninstall

Ankit
  • 1