Flutter "pub get failed" - Connection & Cache Errors in CI
By Daniel Zoghalchali·Latchkey
Pub failed to fetch packages from pub.dev. Unlike version-solving failures, this is a download/cache problem - a transient network error or a corrupt local pub cache - and usually clears on retry or a cache repair.
What this error means
flutter pub get fails with a connection-closed, timeout, or "Hash mismatch"/"Failed to extract" error while downloading. Re-running often works, and repairing the pub cache fixes a corrupt download.
pub output
Connection closed while receiving data, package:dio.
pub get failed
Failed to extract package:image to cache: hash mismatch.
Common causes
Transient pub.dev network failure
A dropped connection or timeout while downloading a package. These are flaky and unrelated to your constraints.
Corrupt or partial pub cache
A previous interrupted download left a bad archive in ~/.pub-cache, so extraction fails with a hash mismatch until the cache is repaired.
How to fix it
Retry, then repair the cache
Retry the fetch; if a hash mismatch persists, repair the cache to re-download corrupt entries.
On networks that cannot reach pub.dev directly, point pub at an internal mirror.
Terminal
export PUB_HOSTED_URL=https://pub.your-mirror.example.com
flutter pub get
How to prevent it
Cache ~/.pub-cache keyed on pubspec.lock.
Wrap pub get with a pub cache repair fallback for corruption.
Use an internal mirror for high-volume or restricted pipelines.
Frequently asked questions
What causes ""pub get failed""?
A dropped connection or timeout while downloading a package. These are flaky and unrelated to your constraints.
How do I fix "pub get failed"?
Retry the fetch; if a hash mismatch persists, repair the cache to re-download corrupt entries.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.