11

I am using Windows 10 and composer is installed. When I try to install laravel installer globally using this command:

composer global require laravel/installer

[Composer\Downloader\TransportException]
The "https://repo.packagist.org/packages.json" file could not be downloaded: 
failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

It means package not downloaded. I am not using any proxy server. Composer diagnose result is listed below:

Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: 
[Composer\Downloader\TransportException] The "http://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Checking https connectivity to packagist: 
[Composer\Downloader\TransportException] The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Checking github.com rate limit: FAIL
[Composer\Downloader\TransportException] The 
"https://api.github.com/rate_limit" file could not be downloaded: failed to 
open stream: A connection attempt failed because the connected party did not 
properly respond after a period of time, or established connection failed 
because connected host has failed to respond.

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.8.0
PHP version: 7.2.1
PHP binary path: E:\xampp\php\php.exe
Diptangsu Goswami
  • 5,554
  • 3
  • 25
  • 36
Gurpal singh
  • 1,511
  • 1
  • 14
  • 27
  • Could be network issue. Did you try with a different internet connection? – Shakeel Dec 31 '18 at 10:14
  • yes i have tried with 3-4 networks and when i am connecting another system with those network it is working fine. – Gurpal singh Dec 31 '18 at 10:16
  • Why would you manually install it when you can use laragon? (https://laragon.org/) – Andy Dec 31 '18 at 10:22
  • are you able to open the link (`https://repo.packagist.org/packages.json`) in your browser? – treyBake Dec 31 '18 at 10:24
  • Hi Andy, I don't have the idea about laragon. – Gurpal singh Dec 31 '18 at 10:24
  • @Andy manual is way better. I know what I'm downloading when I do it. Who knows fully if Laragon adds anything or not. Plus downloading another local server doesn't make sense to this question ... – treyBake Dec 31 '18 at 10:24
  • Hi treyBake, I am able to open (https://repo.packagist.org/packages.json) url in browser – Gurpal singh Dec 31 '18 at 10:25
  • @Gurpalsingh how did you install Composer? – treyBake Dec 31 '18 at 10:30
  • Composer installed using .exe file for window. It was successfully installed. – Gurpal singh Dec 31 '18 at 10:32
  • @Gurpalsingh have you tried via cmd line https://getcomposer.org/download/ ? (commands may differ for Windows) – treyBake Dec 31 '18 at 10:46
  • Yes, I am trying but i am looking same error. PHP Warning: copy(https://getcomposer.org/installer): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. – Gurpal singh Dec 31 '18 at 10:50
  • seems like a networking error. Try disabling IPv6 on your network adapter. - https://github.com/composer/composer/issues/4888 https://medium.com/@JockDaRock/disabling-ipv6-on-network-adapter-windows-10-5fad010bca75 https://getcomposer.org/doc/articles/troubleshooting.md#operation-timed-out-ipv6-issues- – Devin Crossman Jan 04 '19 at 17:11
  • Hi Devin, I tried this one also but nothing happen. – Gurpal singh Jan 04 '19 at 17:12
  • Won't you happen to have Windows firewall enabled for output connections? (this is a *very* long shot, but...) Maybe composer is not allowed to make network connections? – mTorres Jan 06 '19 at 09:59
  • I tried with disable the window firewall. But nothing happen same error comming. – Gurpal singh Jan 06 '19 at 16:04
  • Are you using any proxy ? – Naveen K Jan 07 '19 at 13:10
  • I am not using any proxy or proxy server – Gurpal singh Jan 07 '19 at 13:13
  • I had the exact same issue, ipv6 issue on my PC, solved it by adding `139.99.121.122 repo.packagist.org` to hosts file. – Munim Munna Jan 08 '19 at 15:13

6 Answers6

8

To resolve this, configure composer to use the https repository by running the following command on the cli before installing Laravel

composer config -g repo.packagist composer https://packagist.org
Udo E.
  • 2,665
  • 2
  • 21
  • 33
  • 1
    This was suggested by a contributor to the composer project on github here https://github.com/composer/composer/issues/5656. Plus, it worked flawlessly for me when i had same issue. – Udo E. Jun 25 '19 at 12:09
3

Do you use any antivirus? If yes try to disable then check.

Sometime Mcafe prevent to download packagist.

2

The following steps will fix most "packages.json file could not be downloaded" issue with Composer:

  1. Verify your firewall setting. Disable Firewall for starters
  2. Enable PHP OpenSSL Extension
  3. Enable PHP allow_url_fopen directive

Note: Make sure you are working with the right PHP version and Environment (apache, CLI, etc.) when you modify the php.ini file.

Solomon A.
  • 491
  • 4
  • 7
  • Hi Solomon, I am using window 10 64bit with XAMPP and php 7.2 version. i also tried with php 7.3 and window not connecting with the third party software like teamviewer. 1. Window firewall is disable 2. openssl is enable 3. enabled php allow_url_fopen – Gurpal singh Jan 08 '19 at 06:32
  • Hi Gurpal, for some reason, I missed your comment. I believe the issue you were having is related to TeamViewer hijacking the ports 80 and 443. Follow the instruction on this answer to resolve the issue: https://serverfault.com/a/356117 I know it has been a while, and you don't need this answer. Hopefully, it helps someone else. – Solomon A. May 26 '20 at 16:21
0

I believe you are facing the same issue as this and this. Composer recommends the following:

We recommend you fix your IPv6 setup. If that is not possible, you can try the following workarounds:

sadly, for the Windows workaround it says that if your setup cannot be fixed or if that didn't solve the issue then you should outright disable IPv6 which is a common answer and is also suggested here (however the video has been deleted so I've made this post to have a reliable answer).

(I've purposely aligned the windows as such so you can see the steps to the screen)

  • Open Control Panel
  • Navigate to Network and Internet
  • Click on Network and Sharing Centre
  • On the left hand side of the window click on Change adapter settings
  • Find your adapter and open the properties by right clicking on it
  • Find Internet Protocol Version 6 (TCP/IPv6) and uncheck it
  • Click OK

Edit #1

What is suggested here is:

Install a Windows level VPN or proxy switcher that acts as the default route if you need to change your IP (effectively). Try CyberGhost

and that seemed to solve the issue for the OP.

Script47
  • 14,230
  • 4
  • 45
  • 66
0

I noticed this is also happening when changing networks (moving from office to office for example). How I managed to solve it is to restart the docker container. I had this situation happening 2 times already and the same solution helped.

Herr Nentu'
  • 1,438
  • 3
  • 18
  • 49
0

All you need to do is to run your cmd/git as Administrator, no need to uninstall anything.

Abbas Fechit
  • 111
  • 8