flutter
install_error
ai_generated
true
Pub get failed (server unavailable) -- Could not resolve packages due to socket exception: OS Error: Connection refused
ID: flutter/install-error-pub-get-failed-socket
82%Fix Rate
87%Confidence
1Evidence
2024-01-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| flutter 3.10 | active | — | — | — |
| flutter 3.22 | active | — | — | — |
| dart 3.0 | active | — | — | — |
| dart 3.5 | active | — | — | — |
Root Cause
The pub.dev server or a custom package repository is unreachable due to network issues, firewall blocking, or DNS resolution failure.
generic中文
由于网络问题、防火墙阻止或 DNS 解析失败,pub.dev 服务器或自定义包仓库无法访问。
Official Documentation
https://dart.dev/tools/pub/troubleshootWorkarounds
-
85% success Check network connectivity and ensure pub.dev is accessible. Temporarily disable VPN or firewall, then run 'flutter pub get --offline' if dependencies are already cached, or use a mirror like 'dart pub get --no-precompile' with PUB_HOSTED_URL set to a mirror.
Check network connectivity and ensure pub.dev is accessible. Temporarily disable VPN or firewall, then run 'flutter pub get --offline' if dependencies are already cached, or use a mirror like 'dart pub get --no-precompile' with PUB_HOSTED_URL set to a mirror.
-
80% success Use a different DNS server (e.g., Google DNS 8.8.8.8) or add an exception for pub.dev in the firewall/proxy settings.
Use a different DNS server (e.g., Google DNS 8.8.8.8) or add an exception for pub.dev in the firewall/proxy settings.
中文步骤
检查网络连接并确保 pub.dev 可访问。临时禁用 VPN 或防火墙,然后运行 'flutter pub get --offline'(如果依赖已缓存),或使用镜像,设置 PUB_HOSTED_URL 为镜像地址。
使用不同的 DNS 服务器(例如 Google DNS 8.8.8.8)或在防火墙/代理设置中添加 pub.dev 的例外。
Dead Ends
Common approaches that don't work:
-
Repeatedly running 'flutter pub get' without any network changes
95% fail
The underlying network issue persists; retrying does not resolve connectivity problems.
-
Deleting the pubspec.lock file and running pub get again
85% fail
The lock file is not the cause; the error is network-related, so deletion has no effect.