Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Composer cannot reach repo.packagist.org on port 443

ErrorFailed to download ... curl error 28 while downloading

Short answer

When Composer cannot reach repo.packagist.org, run composer diagnose first; it tests the connection and the certificate store. The usual causes are a broken IPv6 route (force IPv4 with COMPOSER_IPRESOLVE=4), a network that needs proxy variables, or an outdated CA certificate bundle.

  • Applies to Composer 2, PHP 8.3, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run Composer's own checks. They test the connection to Packagist and show where Composer looks for a CA bundle.

    composer diagnose
    composer diagnose -vvv
  2. 2Match what you see, then jump to its fix

    1. 1The connection hangs or times out, and other tools on IPv4 reach the same hostIPv6 is advertised but does not workFix
    2. 2Other tools work only through a proxy, or the company network blocks direct HTTPSThe network requires a proxy and Composer has noneFix
    3. 3composer diagnose reports an SSL or certificate problem instead of a timeoutThe CA certificate bundle is missing or out of dateFix
    4. 4The failure says the operation was too slow or timed out after 300000 millisecondsA slow link makes a download stallFix

What does the error look like?

  • Failed to download ... curl error 28 while downloading
  • Operation timed out after 300000 milliseconds

Cause 1 of 4

IPv6 is advertised but does not work

1Check

Composer's troubleshooting guide says that if you use IPv6 you should try disabling it. Forcing IPv4 for one run tests that without touching the system.

COMPOSER_IPRESOLVE=4 composer diagnose

2Fix

Set COMPOSER_IPRESOLVE to 4 for Composer (this works when the curl extension does the downloads), or fix IPv6 on the network.

export COMPOSER_IPRESOLVE=4
composer install

3Verify

composer install now downloads packages.

composer diagnose

Confirmed by getcomposer.org

Did this fix it?

Cause 2 of 4

The network requires a proxy and Composer has none

1Check

Composer reads its proxy from environment variables. Without them it tries to connect directly.

env | grep -i proxy

2Fix

Set the proxy variables in the shell (lowercase names are preferred) and list hosts that must bypass the proxy in no_proxy.

export http_proxy=http://proxy.example.com:80
export https_proxy=http://proxy.example.com:80
export no_proxy=localhost

3Verify

Run composer diagnose again.

composer diagnose

Confirmed by getcomposer.org

Did this fix it?

Cause 3 of 4

The CA certificate bundle is missing or out of date

1Check

The troubleshooting guide says to check that the root certificate store or CA bundle is up to date. diagnose -vvv shows which location Composer uses.

composer diagnose -vvv

2Fix

Download a current cacert.pem from the curl project, store it where Composer looks, or point Composer at it with COMPOSER_CAFILE.

export COMPOSER_CAFILE=/path/to/cacert.pem

3Verify

Run composer diagnose; the SSL check passes.

composer diagnose

Confirmed by getcomposer.org

Did this fix it?

Cause 4 of 4

A slow link makes a download stall

1Check

Composer gives up on a download that stalls. The guide names a stall timeout that can be raised.

composer install -vvv

2Fix

Raise the stall timeout (0 disables it) and the PHP socket timeout in php.ini.

export COMPOSER_HTTP_STALL_TIMEOUT=120

3Verify

Run composer install again.

composer install

Confirmed by getcomposer.org

Did this fix it?

How do I stop it coming back?

  • Add COMPOSER_IPRESOLVE=4 or the proxy variables to the CI and server environment once, instead of per command.
  • Keep the OS CA certificates updated with the regular package updates.
  • Run composer diagnose in the first step of any CI job that installs dependencies.

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

Back end

CodeIgniter 4 cannot write its cache files

CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/

CodeIgniter 4's file cache needs a cache directory that the web server can really write to.

2 causes, each with a fix

Back end

CodeIgniter 3 loads the model but the property is undefined

The model name you are loading is the name of a resource that is already being used: user

CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.

2 causes, each with a fix

Next step

Want this handled for good?

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