sdk: dotnet restore fails behind proxy using windows authentication

Steps to reproduce

  • set nuget http_proxy as described here
  • validate that “classic” nuget actually works
  • create new basic app using dotnet new
  • restore packages using dotnet restore

Actual behavior

log  : Restoring packages for C:\TEAH\SRC\HelloWorld\project.json...
info :   GET https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json
info :   ProxyAuthenticationRequired https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json 14ms
log  : Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json'.
log  : Response status code does not indicate success: 407 (Proxy Authentication Required).
info :   GET https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json
info :   ProxyAuthenticationRequired https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json 10ms
log  : Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json'.
log  : Response status code does not indicate success: 407 (Proxy Authentication Required).
info :   GET https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json
info :   ProxyAuthenticationRequired https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json 11ms
error: Failed to retrieve information from remote source 'https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json'.
error: Response status code does not indicate success: 407 (Proxy Authentication Required).
error: Failed to retrieve information from remote source 'https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json'.
error:   Response status code does not indicate success: 407 (Proxy Authentication Required).

Environment data

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 22
  • Comments: 32 (11 by maintainers)

Most upvoted comments

I’m currently using Fiddler as a local proxy using the “Automatically Authenticate” rule for our corporate proxy while the nuget config points to http://127.0.0.1:8888. Not very handy, but works as a temporary workaround.

This is pretty huge. I’m experiencing this as well. It’s a complete blocker for us.

I had a similar issue, inside our corporate network, NuGet was not able to restore packages and the error read: “Proxy Access Denied”. I followed two different Posts on StackOverflow to fix this issue.

First, you need to find the address of your proxy server: http://superuser.com/a/346376

And then you can download NuGet and configure it from the command line (http://stackoverflow.com/a/15463892/394348).

This configuration worked for me: nuget.exe config -set http_proxy=http://YOUR PROXY ADDRESS HERE nuget.exe config -set http_proxy.user=YOUR DOMAIN\YOUR WINDOWS ID

In my case I didn’t need to set my password which is good. Hope this helps

@brthor @degrim, I’m wondering … I got the issue too, and here is all I tried 😃

I’ve installed .Net Core RC 2 Preview One on top of Vs2015.2 I’ve also installed the nuget Vsix 3.5.0 beta

I’m created a new Web>Asp.Net Core Web Application (.NET Framework) named “ReactDemo”

When I try to Right click on the node “References> Restore packages” here is the full log :

C:\Program Files\dotnet\dotnet.exe restore “D:\Sources\ReactDemo.vs\restore.dg” log : Restoring packages for D:\Sources\ReactDemo\src\ReactDemo\project.json… log : Restoring packages for tool ‘Microsoft.AspNetCore.Server.IISIntegration.Tools’ in D:\Sources\ReactDemo\src\ReactDemo\project.json… info : GET https://www.nuget.org/api/v2/FindPackagesById()?id=‘Microsoft.NETCore.DotNetHostResolver’ info : ProxyAuthenticationRequired https://www.nuget.org/api/v2/FindPackagesById()?id=‘Microsoft.NETCore.DotNetHostResolver’ 46ms log : Retrying ‘FindPackagesByIdAsyncCore’ for source ‘https://www.nuget.org/api/v2/FindPackagesById()?id=‘Microsoft.NETCore.DotNetHostResolver’’. log : Response status code does not indicate success: 407 (Proxy Authentication Required). info : GET https://www.nuget.org/api/v2/FindPackagesById()?id=‘Microsoft.NETCore.DotNetHostResolver’ info : ProxyAuthenticationRequired https://www.nuget.org/api/v2/FindPackagesById()?id=‘Microsoft.NETCore.DotNetHostResolver’ 22ms log : Retrying ‘FindPackagesByIdAsyncCore’ for source ‘https://www.nuget.org/api/v2/FindPackagesById()?id=‘Microsoft.NETCore.DotNetHostResolver’’. log : Response status code does not indicate success: 407 (Proxy Authentication Required). info : GET https://www.nuget.org/api/v2/FindPackagesById()?id=‘Microsoft.NETCore.DotNetHostResolver’ info : ProxyAuthenticationRequired https://www.nuget.org/api/v2/FindPackagesById()?id=‘Microsoft.NETCore.DotNetHostResolver’ 20ms error: Failed to retrieve information from remote source ‘https://www.nuget.org/api/v2/FindPackagesById()?id=‘Microsoft.NETCore.DotNetHostResolver’’. error: Response status code does not indicate success: 407 (Proxy Authentication Required). error: Failed to retrieve information from remote source ‘https://www.nuget.org/api/v2/FindPackagesById()?id=‘Microsoft.NETCore.DotNetHostResolver’’. error: Response status code does not indicate success: 407 (Proxy Authentication Required).

When I try in the command prompt from one of these folders : "D:\Sources\ReactDemo" "D:\Sources\ReactDemo\src" “D:\Sources\ReactDemo\src\ReactDemo”

dotnet restore I got the EXACT same log

Then I went to nuget.org and downloaded “nuget.exe” (v3.4.x) and within the folder “D:\Sources\ReactDemo\src\ReactDemo”

nuget restore -NoCache

This is actually working …

That beeing said … I tried it after removing : %USERPROFILE%.nuget\packages %ProgramData%\NuGet\Config (temporaly)

I’ve disabled the Offline nuget feed from nuget.config : Can be found here : %AppData%\NuGet\Nuget.Config (or uncheck from VS IDE)

<disabledPackageSources> <add key="Microsoft Visual Studio Offline Packages" value="true" /> </disabledPackageSources>

I’ve also tried with AND WITHOUT nuget settings : HTTP_PROXY / HTTP_PROXY.USER / HTTP_PROXY.PASSWORD It still works without :

nuget restore -NoCache

Restoring packages for D:\Sources\ReactDemo\src\ReactDemo\project.json...
[huge list of GET / OK / Installing packages]
Restoring packages for tool '.....
Committing restore...
D:\Sources\ReactDemo\src\ReactDemo\project.json
Restore completed in 6717ms.

NuGet Config files used: C:\Users\ahertogs031416\AppData\Roaming\NuGet\NuGet.Config C:\ProgramData\nuget\Config\Microsoft.VisualStudio.Offline.config

Feeds used: https://www.nuget.org/api/v2/

Installed: 48 package(s) to D:\Sources\ReactDemo\src\ReactDemo\project.json

That beeing said how can dotnet restore fail on proxy when nuget restore works if quote : dotnet restore simply forwards to NuGet.

Thankyou @juanreyesv

To reiterate the steps:

  • download the command line version of nuget
  • add it to the path env var
  • nuget.exe config -set http_proxy=http://YOUR PROXY ADDRESS HERE
  • nuget.exe config -set http_proxy.user=YOUR DOMAIN\YOUR WINDOWS ID
  • Dotnet restore etc

In my case, I’m using cntlm to interface with my proxy.

I still have issues with this and don’t know whom to blame 😉 IMO, even if dotnet restore “does nothing but invoke this dll”, it’s too easy to hand over the responsibility to another project - maybe you have to call it with another parameter/setting/environment variable/you name it…

What I’ve investigated so far: nuget restore works like a charm with and without the settings http_proxy, http_proxy.user and http_proxy.password in nuget.exe.config (nuget v3.5.0.1996)… Without the settings it uses the system settings.

However, dotnet restore doesn’t work at all here (dotnet 1.0.0-preview2-1-003177) And I even can see the reason (with WireShark): nuget restore : CONNECT api.nuget.org:443 HTTP/1.1 , NTLMSSP_AUTH, User: DOMAIN\USER dotnet restore: CONNECT api.nuget.org:443 HTTP/1.1 , NTLMSSP_AUTH, User: PROXY_DOMAIN\USER

With PROXY_DOMAIN I really mean the domain part of the http_proxy-setting (or system setting), and this is just wrong here (maybe someone else could confirm that behaviour).


I doublechecked if the config file is used by dotnet, too - and it is used (at least partly as also mentioned by @veb82).

If I add http_proxy, the proxy is used, otherwise not (so yes, the config file is used). If I add http_proxy.user (“DOMAIN\User”, “User” only, wrong user), nothing happens. If I add a username to the proxy url, nothing happens, too…

So it seems that dotnet restore only uses the domain part of the proxy setting.


I see that dotnet restore internally calls msbuild.exe, so @jbeacham’s solution might work, but (currently) not for me…


edit My latest investigation: In my company we have a pac-script that splits the incoming proxy requests onto multiple proxy servers (simple loadbalancing based on the ip-adress) If I use one of those proxys directly as http_proxy, it works… (not a solution I like - but it’s the first time I get dotnet restore to work here). Maybe that’s the reason why not everyone behind a proxy has such problems…

@gafemoyano @axelheer @Michael-D-Pine Opening Fiddler was the only way I could restore packages successfully as well. There is a setting in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config file that was setting the defaultProxy and causing my get package requests to certain nuget domains to timeout.

<system.net> <defaultProxy> <proxy usesystemdefault="true" /> </defaultProxy> </system.net>

Setting usesystemdefault=“false” fixed my issue.

@Michael-D-Pine try setting the http_proxy value of the NuGet Config File to point to your local CNtlm installation (e.g. http://127.0.0.1:3128)