'Got socket error trying to find package cupertino_icons at https://pub.dartlang.org

Whenever i try to create a new project in flutter through git bash or command prompt, i keep on getting this error Got socket error trying to find package cupertino_icons at https://pub.dartlang.org. I have upgraded the flutter sdk to the latest version but still the same problem. Please how do i solve this issue. Thanks



Solution 1:[1]

I would advice anyone that might still be having this problem to TRY the following simply steps:

  1. open environment variable settings
  2. create a new variable with the name: PUB_HOSTED_URL and its value: https://pub.flutter-io.cn
  3. create a new variable with the name: FLUTTER_STORAGE_BASE_URL and its value: https://storage.flutter-io.cn

This did it for me. After spending weeks tryna figure it out. Would love to save someone the headache i went through.

Solution 2:[2]

Spent 2 hours on it myself, in addition to the previous settings, check your antivirus, mine automatically blocked flutter, so disable your antivirus completely it and then try running again, hope this helps someone.

Solution 3:[3]

I have both issues. With:

  1. Corporate firewall. Look here for solution
  2. Env variables (Win system env vars). Create two of them:

Solution 4:[4]

On Linux, this worked for me and for many other people... It should work for you too.

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

On windows, you should create an environment variable with:

name: PUB_HOSTED_URL
 
value: https://pub.flutter-io.cn

name: FLUTTER_STORAGE_BASE_URL

value: https://storage.flutter-io.cn

Solution 5:[5]

I have found that resetting your wifi router works. It's happened to me twice and it worked after I reset my router.

Solution 6:[6]

Using a VPN for access to the internet did the trick for me.

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 Kas Elvirov
Solution 2 boutonz
Solution 3 Kas Elvirov
Solution 4 Mathias Godwin
Solution 5 M. Hagos
Solution 6 D_Edet