Skip to content
Advertisement

DNS resolver issue Composer 2

Composer version: 2.0.4

OS: macOS 10.15.7

When I run composer diagnose I get DNS resolver issue as seen in the attached image

I am able to ping getcomposer.org, packagist.org, github.com – all sites from the terminal.

curl -i packagist.org -L also works as expected without any error

Yet with composer diagnose I am getting DNS resolver issue

This started happening after I upgraded PHP from 7.4.1 to 7.4.12 and updating to composer 2

What could be the issue and how can I fix it

As searchable text code – composer 2.0.4 diagnose failing

$ composer diagnose
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: FAIL
The following exception probably indicates you have misconfigured DNS resolver(s)
[ComposerDownloaderTransportException] Resolving timed out after 10003 milliseconds
Checking https connectivity to packagist: FAIL
The following exception probably indicates you have misconfigured DNS resolver(s)
[ComposerDownloaderTransportException] Resolving timed out after 10003 milliseconds
Checking github.com rate limit: FAIL
[ComposerDownloaderTransportException] Resolving timed out after 10004 milliseconds
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: FAIL
[ComposerDownloaderTransportException] Resolving timed out after 10002 milliseconds
Composer version: 2.0.4
PHP version: 7.4.12
PHP binary path: /usr/local/Cellar/php/7.4.12/bin/php
OpenSSL version: OpenSSL 1.1.1h  22 Sep 2020
cURL version: 7.73.0 libz 1.2.11 ssl OpenSSL/1.1.1h
zip extension: OK

Screenshot – composer 2.0.4 diagnose failing enter image description here

I just uninstalled composer 2.0.4 and installed composer 1.10.17 with rest of the packages/apps as it is and it runs without any DNS resolver error

As searchable text code composer 1.10.17 diagnose

composer diagnose
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: 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: You are not running the latest stable version, run `composer self-update` to update (1.10.17 => 2.0.4)
Composer version: 1.10.17
PHP version: 7.4.12
PHP binary path: /usr/local/Cellar/php/7.4.12/bin/php
OpenSSL version: OpenSSL 1.1.1h  22 Sep 2020

Screenshot – composer 1.10.17 diagnose composer 2.0.4 diagnose failing

So does it mean that composer 2.0.4 has some issues? or is incompatible with my setup of other apps/packages?

I want to use composer 2.x, so what do I do to make it work?

Advertisement

Answer

In the end, it’s not a “composer” problem, but of the underlying connectivity technology. Composer 2 uses curl by default, whereas Composer 1 used PHP streams… and apparently they are not equally sensitive or forgiving to different network configurations and misconfigurations.

Some things to check and re-check:

  • Your DNS settings. Check that there are no wrongly configured entries. Just for the sake of it change if you can your DNS provider to a “known good” one. E.g. Cloudflare’s (1.1.1.1), or Google’s (8.8.8.8, 8.8.4.4), and remove all other entries.

  • IPV6 connectivity. You many need to disable it if you have it enabled, since some users reported issues with it.

  • Disable any VPNs you may be using to connect to the Internet, since they may interfere with your connectivity.

On this issue some users have commented on similar problems.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement