Reza Mojed
Reza Mojed

Reputation: 1077

When I wnat to get package flutter it show me HTTP error 403: Forbidden

I am working on flutter project in Intellij Idea. when I want to add a package in pubspec.yaml, it leads to below errror:

HTTP error 403: Forbidden


package:pub/src/http.dart 218:5                 _ThrowingClient.send
===== asynchronous gap ===========================
package:http_throttle/http_throttle.dart 33:31  ThrottleClient.send
===== asynchronous gap ===========================
package:pub/src/source/hosted.dart 322:37       BoundHostedSource._download
===== asynchronous gap ===========================
package:pub/src/source/hosted.dart 217:13       BoundHostedSource.downloadToSystemCache
===== asynchronous gap ===========================
package:pub/src/entrypoint.dart 374:48          Entrypoint._get.<fn>

===== asynchronous gap ===========================
dart:async                                      runZoned
package:pub/src/http.dart 272:10                withDependencyType
package:pub/src/entrypoint.dart 370:12          Entrypoint._get
dart:async                                      Future.wait
package:pub/src/entrypoint.dart 231:18          Entrypoint.acquireDependencies
dart:async                                      _completeOnAsyncReturn
package:pub/src/solver/version_solver.dart      VersionSolver.solve
dart:async                                      _completeOnAsyncReturn
package:pub/src/solver/version_solver.dart      VersionSolver._result
This is an unexpected error. Please run

pub --trace '--verbosity=warning' get --no-precompile

and include the logs in an issue on https://github.com/dart-lang/pub/issues/new

I have tried using vpn and without vpn both of them doesnt work. Also, when i add some common package such as provider or http, its fine.

This is my code:

dependencies:
 flutter:
     sdk: flutter
 flutter_localizations:
     sdk: flutter

 provider: ^3.2.0
 http: ^0.12.0+2
 font_awesome_flutter: ^8.5.0
 flutter_rating_bar: ^3.0.0

my flutter sdk version : flutter_windows_v1.9.1+hotfix.6-stable_3

Could you please help me?

Thanks in advance

Upvotes: 2

Views: 8133

Answers (6)

M Karimi
M Karimi

Reputation: 3523

It often related to VPN connection. before running flutter pub get, being sure that you can open https://developer.android.com/ site.

Upvotes: 0

iman havangi
iman havangi

Reputation: 1

After hours of trying to solve this problem, I finally found a solution.

First, you have to delete all the packages of project from pubspec.yaml file (you can comment these lines, so you don't forget what's packages used)

then add all the packages to the project from cmd with this command:

flutter pub add <package_name>

Make sure to use cmd, not powershell.

I hope this solution works for you.

Upvotes: 0

Mahan
Mahan

Reputation: 201

I had exactly the same problem and changed a few VPN, but it was still a problem and did not work

I used a service that changed DNS to fix the problem of sanctions and the problem was solved

Upvotes: 0

Golnar sheikh bahaie
Golnar sheikh bahaie

Reputation: 202

same problem happened for me so i just did

1:flutter clean

2:use 2 vpn at same time

this problem happened because of your connection ;)

Upvotes: 4

user6130977
user6130977

Reputation: 1

It may solve your problem:

  1. add ".catch-pub" folder in your current project
  2. add global environment variable "PUB_HOSTED_URL" with value "https://pub.dev/"

Upvotes: 0

Javad.rajabi
Javad.rajabi

Reputation: 217

use proxy or vpn your ip address is block https://dart.dev/tools/pub/troubleshoot#pub-get-fails-from-behind-a-corporate-firewall

Upvotes: 0

Related Questions