composer: The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: No connection could be made because the target machine actively refused it.
My composer.json
:
{
"name": "ricadiz/composer",
"require": {}
}
Output of composer diagnose
:
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: WARNING
[Composer\Downloader\TransportException] The "http://packagist.org/packages.json" file could not be downloaded: failed to open stream: No connection could be made because the target machine actively refused it.
Checking https connectivity to packagist: WARNING
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: No connection could be made because the target machine actively refused it.
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0 87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B 0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 1.6.5
PHP version: 7.2.7
PHP binary path: D:\xampp7\php\php.exe
When I run this command:
composer create-project --prefer-dist laravel/laravel testapp
I get the following output:
[Composer\Downloader\TransportException]
The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: No connection could
be made because the target machine actively refused it.
Basically I was trying to setup composer in a corporate environment to enable to work with Laravel projects. I freshly installed latest XAMPP. But I have already spent days looking for solution on how to make composer work. I have already tried the following:
- Disable IPv6 wireless connection (Since I’m currently using laptop)
- Set/Remove environment variables (tried http_proxy alone, http_proxy, https_proxy, HTTP_PROXY, HTTP_PROXY, all four of them) but still would fail somehow
- Did restart every set of env variables
- Removed all the environment proxy variable and manually doing
export HTTP_PROXY=....
andexport HTTPS_PROXY=...
- Yes, I use credentials in my proxy
username:password@host:port
Additional notes:
- I used the windows installer to install composer, and I noticed that the installer doesn’t accept leading
http://
orhttps://
in the proxy field during installation. Which I also spent days troubleshooting how to install composer. I’m not using VM for now. - I installed latest
cURL
and tried the following command:curl https://packagist.org/package.json -vv
And somehow got the json from the respose:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1456 100 1456 0 0 3586 0 --:--:-- --:--:-- --:--:-- 3586{"packages":[],"notify":"https://packagist.org/downloads/%package%","notify-batch":"https://packagist.org/downloads/","providers-url":"/p/%package%$%hash%.json","search":"https://packagist.org/search.json?q=%query%&type=%type%","provider-includes":{"p/provider-2013$%hash%.json":{"sha256":"99bae025d4d2e751a27fe35e136f601de188eda7077be4d5f63a549ea97907db"},"p/provider-2014$%hash%.json":{"sha256":"9406108133abe969d70795f837a3a9f72b416d25ca63944d1fc43355fde3cacf"},"p/provider-2015$%hash%.json":{"sha256":"9e6c81496931a07012024abf1cf1c114e8b86188f643d9a6f5481dbda26d02cd"},"p/provider-2016$%hash%.json":{"sha256":"7a798e4cb4e4191c3932f06c5d6cf099b1397df3d8eee73f61f73ca8f6dbe917"},"p/provider-2017$%hash%.json":{"sha256":"31a86e95e9ba4cae26868d352250c93c2c20f8ff6f454cf7086ba066c1877e3c"},"p/provider-2017-10$%hash%.json":{"sha256":"b2da560198469600563d4428b4c7c769601802154d16b224cb559404567cad72"},"p/provider-2018-01$%hash%.json":{"sha256":"b1959d2e442d85a41d6c5fda0dca0946a342f2da07df60eae618a2ed19421a0d"},"p/provider-2018-04$%hash%.json":{"sha256":"4b39c9ca91e2bba7265b8b1f85bdb8dc522a5c8df00b322adfb43ac3c1d5c4a2"},"p/provider-2018-07$%hash%.json":{"sha256":"93936039e8fd151b21c68a396a7a1217e2d725803a2b54b0e1cad961c76aabfc"},"p/provider-archived$%hash%.json":{"sha256":"939a942590ec7e93239cd4beb63399da3206d5337563e0ac345a5b58f458b46e"},"p/provider-latest$%hash%.json":{"sha256":"793c519d05e378606154e744a199e151f88adb32f526294cd15c78895af3a3a8"}}}
- We’re using a domain user account so basically my proxy authentication looks like this:
domain/username:password
- I can access the url using a web browser
- I got certificate errors for
https://getcomposer.org
also along the way but I already managed to fix it by importing the necessary intermediate ca. - I tried to check run this command
openssl s_client -connect packagist.org:443
and got this response:
connect: No error
connect:errno=0
I would like to be much in detail but I don’t want this post to get long. Thanks.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 27 (3 by maintainers)
based on the link shared by @NwosuCC I sorted it out while trying to install laravel/horizon on Ubuntu using
composer config -g repo.packagist composer https://repo.packagist.org
I was able to resolved my issue now. But now, I’m using vm using Homestead hoping it will fix if I will use Linux, but not all, I don’t think this contribute to the fix.
Anyway as mentioned in my first post I was getting error for the url:
Saying :
during
composer diagnose
but getting OK at the rest, and I was able to take note that error will only occur, if I have not setup properly the proxy or I have not specified any proxy at all.Now if I specified the correct proxy, the error for both URL disappear.
But then I got another error in the part:
Saying:
but as you noticed, I mentioned I got OK when there are no proxy specified in this part.
So that is where the confusion I had I was thinking both were related and it may be because of proxy or certificate but no it’s not.
So what I did after all the digging, I was able to think finally
SOLUTION:
I only applied proxy except to these URLs getting certificate error.
After that, this is now my result:
I would recommend you talk to your network administrator.
This link has a composer config solution that worked for me: https://laravel.io/forum/solved-issues-with-nesbotcarbon
Thanks @threeFatCat
SOLUTION:
I had the same problem, I figured out that I have an other php 5.5 installed along with xampp php version 7.2. So i launched the command (composer create-project symfony/skeleton MyProject) under php 7.2 folder and it was really awesome 😃
It seems that the Composer try to download some files behind HTTP proxy.
Could you use the
composer install -vvv
to present more details?For me all the above solutions didn’t work. However, this did work - networksetup -setv6off Wi-Fi composer create-project --prefer-dist laravel/laravel app123 networksetup -setv6automatic Wi-Fi
Read more about it https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode
Solution by @threeFatCat
resolved thank @threeFatCat.