composer self-update cannot download or replace composer.phar
SSL certificate problem: unable to get local issuer certificateShort answer
composer self-update downloads a new composer.phar and replaces the old one, so it fails for three reasons: the file's folder is not writable for your user, the machine's CA bundle cannot verify the download server, or an IPv6 route times out. Run composer diagnose first, then fix the one it points to.
Fix it fast
1Find out which cause you have
Let Composer check its own setup. It tests connections, the CA file and other common problems, and -vvv shows where it looks for the CA file.
composer diagnose -vvv2Match what you see, then jump to its fix
- 1
composer diagnose is clean, but the update cannot write the file in a system folder such as /usr/local/bin.Your user cannot replace the installed composer.pharFix - 2
SSL certificate problem: unable to get local issuer certificate.The CA bundle is out of date or blocked by security softwareFix - 3
Operation timed out, often while the same URL works over IPv4.An IPv6 route is broken and the download times outFix
- 1
What does the error look like?
SSL certificate problem: unable to get local issuer certificateOperation timed out
Cause 1 of 3
Your user cannot replace the installed composer.phar
1Check
For a system-wide installation, the docs say you may have to run the command with root privileges. Find where Composer is installed and who owns it.
which composer
ls -l "$(which composer)"2Fix
Run the update as the account that owns the installation. Do not make the folder writable for other users: the docs warn that a directory writable by others could be used to plant a malicious composer.phar.
sudo composer self-update3Verify
Check the version after the update.
composer --versionConfirmed by getcomposer.org
Cause 2 of 3
The CA bundle is out of date or blocked by security software
1Check
The troubleshooting page says to check that the root certificate store or CA bundle is up to date, and that diagnose -vvv shows where Composer looks for the CA file.
composer diagnose -vvv2Fix
Replace the CA file with a current cacert.pem, or update the system CA store. On Windows, try turning off antivirus or firewall software to see whether it interferes.
sudo apt update && sudo apt install --only-upgrade ca-certificates3Verify
Run the update again.
composer self-updateConfirmed by getcomposer.org
Cause 3 of 3
An IPv6 route is broken and the download times out
1Check
The docs advise fixing your IPv6 setup; as a workaround they give an environment variable that forces curl to resolve with IPv4, which works only when Composer uses the curl extension.
COMPOSER_IPRESOLVE=4 composer diagnose2Fix
Run the update with COMPOSER_IPRESOLVE=4, or on Linux give IPv4 higher priority in gai.conf as the troubleshooting page shows.
COMPOSER_IPRESOLVE=4 composer self-update3Verify
The update finishes and composer --version shows the new release.
composer --versionConfirmed by getcomposer.org
How do I stop it coming back?
- Run composer self-update on a schedule on build servers, so you do not jump many versions at once.
- Keep the OS CA certificates updated with your normal system updates.
- Use composer self-update --rollback if a new release breaks a build; Composer keeps the last version you had installed.
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 or PHP stream fails with certificate verify failed
SSL certificate problem: unable to get local issuer certificate
PHP could not check the server's TLS certificate against a trusted CA file.
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