'Flutter doctor: Unable to download dart sdk,BITS service failed in windows

error showing:

Downloading the Dart SDK using the BITS service failed, retrying with WebRequest...
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At C:\src\flutter\bin\internal\update_dart_sdk.ps1:68 char:5
+     Invoke-WebRequest -Uri $dartSdkUrl -OutFile $dartSdkZip
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Please, I need help I'm new in flutter.



Solution 1:[1]

use VPN and try running the command again. it worked for me.

Solution 2:[2]

I had the same problem.

You need to have access to internet and run then run

flutter doctor

from the command line or terminal. It should download the Dart SDK and some other tools.

My output after running flutter doctor:

flutter doctor from command line

Solution 3:[3]

Don't run an elevated command prompt - run it as a user command prompt instead.

enter image description here

Solution 4:[4]

Firstly run in terminal:

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

then dart sdk download successfully in my MAC.

You have to add PUB_HOSTED_URL=https://pub.flutter-io.cn && FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn in environment. Try again.

Solution 5:[5]

Simply run

Flutter doctor

in the PowerShell as administrator. I hope this resolves your issue :).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gs Sagor
Solution 2 Bhargav Rao
Solution 3 Zoe stands with Ukraine
Solution 4 Zoe stands with Ukraine
Solution 5 sachin verma