Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

benelaci's avatar

Composer install fails: SSL: Connection reset by peer

Hello,

I was following the steps on installing composer that can be found here: https://getcomposer.org/download/

I get the following message when trying to run php composer-setup.php:

The "https://getcomposer.org/versions" file could not be downloaded: SSL: Connection reset by peer

Failed to enable crypto

failed to open stream: operation failed

Previously, I wasn't able to download composer-setup.php with php -r copy() command, so I downloaded it via browser. The reason was the same: SSL connection failed.

Thanks in advance for your help!

0 likes
4 replies
Tray2's avatar

Just do a manual download then.

Not knowing your OS but if it's Linux chmod the file with sudo chmod +x composer.phar and them move it to usr/local/bin with mv composer.phar /usr/local/bin/composer

Flor's avatar

It sounds like php does not have a valid path to ssl certificates. You can download curl ssl certificates here:

https://curl.haxx.se/docs/caextract.html

And you can read about configuring PHP with the certificates here:

https://stackoverflow.com/questions/35197412/ssl-error-at-composer-install

If you want to avoid installing composer manually, you could do one of the following:

Windows:

Try using the Windows installer, that will handle everything for you.

MacOS

You can install composer with brew: https://gist.github.com/shashankmehta/6ff13acd60f449eea6311cba4aae900a

Linux

You should be able to install via the distros package manager, for instance: apt-get install composer

benelaci's avatar

Here are the developments.

Tried to fix ssl for composer install

I've downloaded ssl certificates from here: https://curl.haxx.se/docs/caextract.html Then I've enabled/added the following lines in php.ini:

extension=php_curl.dll

extension=php_openssl.dll

curl.cainfo = /Users/benelaci/Sites/__files/cacert.pem

openssl.cafile = /Users/benelaci/Sites/__files/cacert.pem

The ssl connection still fails when I try to run composer-setup.php : SSL: Connection reset by peer

Then I tried a different approach:

Tried to install Composer with Homebrew

Note: I have OSX 10.10, because of which I got a warning from Homebrew that it's too old, and there might be failures.

Although composer.phar does get downloaded, it remains in Homebrew's cache directory, instead of being placed to /usr/bin.

Moving the file manually didn't help. When I tried to install Laravel, composer.json was missing for Composer to run.

I got one seemingly marginal error message from Homebrew while trying to install Composer:

Error: An exception occurred within a child process:

NoMethodError: undefined method `source' for nil:NilClass

Looks like I'm draining all possibililites, but I'm still hoping for a resolution.

Thanks for reading all this, and for the help.

Please or to participate in this conversation.