Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Flutter keeps retrying 'pub upgrade' for its own tool

ErrorError: Unable to 'pub upgrade' flutter tool. Retrying in five seconds...

Short answer

The flutter command rebuilds its own tool and downloads packages from pub.dev to do it. The retry loop means that download fails. Check proxy variables, a mirror set by PUB_HOSTED_URL, and security software blocking dart, then confirm pub.dev is reachable.

  • Applies to Flutter 3.x, Dart 3.x, macOS, Linux, Windows
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check whether this machine can reach pub.dev at all, and whether any pub environment variable is set.

    curl -I https://pub.dev
    env | grep -i "pub_hosted_url\|https_proxy\|http_proxy"
  2. 2Match what you see, then jump to its fix

    1. 1curl works in a browser or VPN session but fails in the terminal, and no https_proxy is setA proxy is needed but pub does not know about itFix
    2. 2The log mentions a socket error while finding a package at pub.devA firewall or security program blocks dartFix
    3. 3env shows PUB_HOSTED_URL, often left from an earlier setupPUB_HOSTED_URL points to a mirror that is down or wrongFix

What does the error look like?

  • Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds...
  • Got socket error trying to find package

Cause 1 of 3

A proxy is needed but pub does not know about it

1Check

From the command line, pub honors the http_proxy and https_proxy environment variables, so a terminal behind a corporate proxy needs them.

echo "$https_proxy"

2Fix

Set the variable for your shell, with credentials if the proxy needs them.

export https_proxy=hostname:port
# with credentials:
export https_proxy=username:password@hostname:port

3Verify

Run Flutter again.

flutter --version

Confirmed by dart.dev

Did this fix it?

Cause 2 of 3

A firewall or security program blocks dart

1Check

Pub's own troubleshooting says to check the connection and to confirm no firewall or security software blocks the dart process.

curl -I https://pub.dev

2Fix

Allow the dart executable, and allow pub.dev in your security product. Some products need pub.dev and pub.dartlang.org added to a trusted zone.

# no command: change the setting in your firewall or security product

3Verify

Run Flutter again.

flutter --version

Confirmed by dart.dev

Did this fix it?

Cause 3 of 3

PUB_HOSTED_URL points to a mirror that is down or wrong

1Check

Pub downloads from pub.dev unless PUB_HOSTED_URL names another server.

echo "$PUB_HOSTED_URL"

2Fix

Unset it, or set it to a mirror that currently works.

unset PUB_HOSTED_URL
# or point it at a mirror you trust:
export PUB_HOSTED_URL=https://pub.example.com

3Verify

Run Flutter again.

flutter --version

Confirmed by dart.dev

Did this fix it?

How do I stop it coming back?

  • Keep proxy and mirror variables in one shell profile, so you know where to look.
  • Check pub.dev reachability first when any Flutter command hangs on a download.
  • Remove temporary mirror settings when you leave the network that needed them.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.