NuGet Package restore failed...The underlying connection was closed.., error in VisualStudio ultimate 2012

bharat 1 Reputation point
2022-10-01T17:10:31.447+00:00

Hi,
Below is machine and VS details:

Windows 7

Visual studio Ultimate 2012 Version 11.0.61219.00 Update 5

Microsoft .NET framework version 4.5.50709

Project: MVC 4 project - C#

Everything was working fine till today; But my laptop suddenly - crash shutdown- with blue screen.

I long press on/off button to start my machine again -> then i select 'Start windows normally ' option

--- then I was asked to restore/Recover I guess & i cancelled this popup....

I Open my VisualStudio 2012 Project ; now suddenly it started giving error like:

Error:
"NuGet Package restore failed for project Mi.Web.Core: The underlying connection was closed: An unexpected error occurred on a send.."

I have gon through many articles / answers on Stackoverflow and other as appear after google search.

I am stuck and cant run my code which was working fine till today morning.... Please help me to solve this issue.
Thanks,.

Developer technologies | .NET | Other
Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,441 Reputation points Microsoft External Staff
    2022-10-03T03:27:22.86+00:00

    Hi @bharat ,

    Welcome to Microsoft Q&A forum.

    For old versions of Visual Studio such as Visual Studio 2012 and Visual Studio 2013, you may get this similar errors. The cause is related to TLS and certificate. I think you can try this: open the NuGet Package Management Console(Tools > NuGet Package Manager > Package Manager Console)(If you can find it in VS 2012. Not very sure if it exists in VS 2012, as VS 2012 is an old version of VS) => enter following command line:

    <code>[Net.ServicePointManager]::SecurityProtocol=[Net.ServicePointManager]::SecurityProtocol-bOR [Net.SecurityProtocolType]::Tls12  
    

    Besides, please go to Tools > NuGet Package Manager > Package Manager Settings > Package Sources > and make sure that nuget.org( https://api.nuget.org/v3/index.json ) is selected, and no other invalid package sources are selected.

    BTW, blue screen maybe indicate that there’s something wrong with your machine’s hardware.

    Best Regards,
    Tianyu

    • If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    2 people found this answer helpful.

  2. Bruce (SqlWork.com) 77,766 Reputation points Volunteer Moderator
    2023-10-04T15:52:32.28+00:00

    The nuget switch to tsl 1.2 was years ago, but maybe this is your first restore. See

    https://devblogs.microsoft.com/nuget/deprecating-tls-1-0-and-1-1-on-nuget-org/

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.