Composer cannot reach repo.packagist.org on port 443
Failed to download ... curl error 28 while downloadingShort 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.
Fix it fast
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 -vvv2Match what you see, then jump to its fix
- 1
The connection hangs or times out, and other tools on IPv4 reach the same hostIPv6 is advertised but does not workFix - 2
Other tools work only through a proxy, or the company network blocks direct HTTPSThe network requires a proxy and Composer has noneFix - 3
composer diagnose reports an SSL or certificate problem instead of a timeoutThe CA certificate bundle is missing or out of dateFix - 4
The failure says the operation was too slow or timed out after 300000 millisecondsA slow link makes a download stallFix
- 1
What does the error look like?
Failed to download ... curl error 28 while downloadingOperation 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 diagnose2Fix
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 install3Verify
composer install now downloads packages.
composer diagnoseConfirmed by getcomposer.org
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 proxy2Fix
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=localhost3Verify
Run composer diagnose again.
composer diagnoseConfirmed by getcomposer.org
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 -vvv2Fix
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.pem3Verify
Run composer diagnose; the SSL check passes.
composer diagnoseConfirmed by getcomposer.org
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 -vvv2Fix
Raise the stall timeout (0 disables it) and the PHP socket timeout in php.ini.
export COMPOSER_HTTP_STALL_TIMEOUT=1203Verify
Run composer install again.
composer installConfirmed by getcomposer.org
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
Composer stops with curl error 28 while downloading packages
Operation timed out after 300000 milliseconds
Curl error 28 is a timeout.
3 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fixBack 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 fixBack 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