osob.de Unicorn Logo
Blogpost overview

Composer\Downloader\TransportException - Failed to open stream: HTTP request failed | 16.02.2020

<p>Today I had a struggle with using Composer in a new Docker environment. For example, while trying to install Symfony, I received this error:</p> <pre>[Composer\Downloader\TransportException]<br>The "http://repo.packagist.org/p/provider-2019-07%2464c3c0374a0541958602c66c4b7654eafc0a265b180945a3fef255312d1890f8.json" file could not be downloaded: failed to open stream: HTTP request failed</pre> <p>A little confused, I started to diagnose:</p> <pre>composer diag</pre> <p>A key error showed up:</p> <pre>Checking platform settings: OK<br>Checking git settings: OK<br>Checking HTTP connectivity to Packagist: OK<br>Checking HTTPS connectivity to Packagist: OK<br>Checking github.com rate limit: OK<br>Checking disk free space: OK<br>Checking pubkeys: FAIL<br>Missing pubkey for tags verification<br>Missing pubkey for dev verification<br>Run composer self-update --update-keys to set them up<br>Checking Composer version: OK<br>Composer version: 1.9.3<br>PHP version: 7.3.14<br>PHP binary path: /usr/bin/php7.3</pre> <p>After adding the keys with composer self-update --update-keys, the command failed again. The next step was to use the -vvv flag in the command to change the verbose output (to get more details). Still the same unexpected result, and the only helpful information was the error as mentioned above (HTTP failed). Next, I checked the URL with wget and had to recognize that the HTTP request failed, but an HTTPS request succeeded. So I performed the following command:</p> <p><code>composer config --global repos.packagist composer <a href="https://packagist.org">https://packagist.org</a></code></p> <p>I don't have a clue where the change came from. But right now, I'm happy because it cost a few hours.</p>

You like what you find here? A donation helps to keep this project running.