composer: Could not connect to packagist.org

My composer.json:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "repositories": [
        {
             "type": "composer", 
             "url": "https://packagist.org"
        }
    ],
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.3.*",
        "laravelcollective/html": "^5.3.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.0",
        "symfony/css-selector": "3.1.*",
        "symfony/dom-crawler": "3.1.*"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

Output of composer diagnose:

C:\xampp\htdocs\contetra>composer diagnose
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: Warning: Accessing packagist.org over http which is an insecure protocol.
FAIL
[Composer\Downloader\TransportException] The "http://packagist.org/packages.json" file could not be downloaded: failed to open stream: A connection attempt failed because
not properly respond after a period of time, or established connection failed because connected host has failed to respond.

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

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

Checking HTTP proxy support for request_fulluri: FAIL
Unable to assess the situation, maybe packagist.org is down (The "http://packagist.org/packages.json" file could not be downloaded: failed to open stream: A connection at
connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
)
Checking HTTPS proxy support for request_fulluri: FAIL
Unable to assess the situation, maybe github is down (The "https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0" file could not be downloaded: failed to open strea
ailed 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
ot 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:

  [Composer\Downloader\TransportException]
  The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: A connection attempt failed because the connected party did not properly res
   time, or established connection failed because connected host has failed to respond.


diagnose

I am using windows. Also, I am unable to open packagist.org site and getcomposer.org website too. PHP version is not the issue, as i am using the latest version.

What can i do to make composer work?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

No but we just want to test packagist connectivity right now. E.g.

curl -vvv https://packagist.org/packages.json
curl -vvv http://packagist.org/packages.json

May this post is old, but I will try it anyway. I’ve got the same error with Composer 2.0.9 Docker image. Trying to download some packages (different ones for testing it in different ways) I have encountered the error also on GitHub URLS (api.github.com and github.com). Composer require commands fail for this error:

[Composer\Downloader\TransportException]
  curl error 6 while downloading https://api.github.com/: Could not resolve host: api.github.com

Even if I run composer diagnose I face the same problem:

/app # composer diagnose
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: FAIL
[Composer\Downloader\TransportException] curl error 6 while downloading https://api.github.com/rate_limit: Could not resolve host: api.github.com
Checking disk free space: OK
Checking pubkeys: OK
Checking composer version: OK
Composer version: 2.0.9
PHP version: 8.0.1
PHP binary path: /usr/local/bin/php
OpenSSL version: OpenSSL 1.1.1i  8 Dec 2020
cURL version: 7.74.0 libz 1.2.11 ssl OpenSSL/1.1.1i
zip: extension present, unzip present

If I upgrade composer to version 2 in my local machine, running the same requires works. Same Network, same all network stuff. The only is difference is the Docker image itself.

Any idea?

EDIT:

For MacOS users, upgrade Docker Desktop to version 3.10 seems partially resolve the problem. I said partially 'cause the host api.github.com continue to be unresolved but now composer seems working going in fallback on the “source” stuff.

Failed to download guzzlehttp/promises from dist: curl error 6 while downloading https://api.github.com/repos/guzzle/promises/zipball/60d379c243457e073cff02bc323a2a86cb355631: Could not resolve host: api.github.com
    Now trying to download from source OK

I don’t know how, but your above reply made me think of port of my server. I checked port 80 of my server. It was blocked due to some file. I deleted that file and unblocked the port. It worked just fine after that.

Strangely, now i am also able to access packagist.org from my computer.

Thanks a lot for all the help. You have been kind.

– Varun DavdaPHP Developer

On Wed, Nov 9, 2016 at 7:37 PM, Niels Keurentjes notifications@github.com wrote:

Depending on your distro possibly, should be in some sort of net-tools package or so. I can’t see which distro you have from your dumps. For Debian/Ubuntu it’s just apt-get install traceroute ( https://packages.debian.org/jessie/traceroute).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/composer/composer/issues/5825#issuecomment-259422437, or mute the thread https://github.com/notifications/unsubscribe-auth/AJf1GTY1mcXeU-fWlMe_LL6lrceNlN94ks5q8dO_gaJpZM4KkE5n .

Depending on your distro possibly, should be in some sort of net-tools package or so. I can’t see which distro you have from your dumps. For Debian/Ubuntu it’s just apt-get install traceroute (https://packages.debian.org/jessie/traceroute).

First step would be to do a traceroute to the affected hosts. It would show whether routing is normal from your computer to the webserver, and whether any weird proxies exist in between.

Also, if you experience an unreachable site, first stop should always be http://downforeveryoneorjustme.com/packagist.org - it’s what the rest of the world is seeing 😃