Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Installing Composer - failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known

I am attempting to use the Composer Dependency Manager for PHP, but I am experiencing the following issue when I use the Composer-Setup.exe (Win32 installer).

Download failed: php_network_getaddresses: getaddrinfo failed: No such host is known. 
failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. 
Download failed: php_network_getaddresses: getaddrinfo failed: No such host is known. 
failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. 
Download failed: php_network_getaddresses: getaddrinfo failed: No such host is known. 
failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. 
The download failed repeatedly, aborting.`

I followed the advice on several other stackoverflow threads for that error, and I've checked some other forums. In my php.ini, I have made sure I have the following options:

allow_url_fopen = On
allow_url_include = On
extension=php_openssl.dll

I also tried the manual installation of Composer, which asks you to execute:

php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"

I get the same error from that. However, If I remove "/installer", it can retrieve the source. I have verified that that the "/installer" URL works. What configuration could cause this behavior? I'm running PHP 5.4 on 32-bit Windows 7.

Thanks, Andrew

like image 701
Andrew Riker Avatar asked Dec 22 '12 06:12

Andrew Riker


2 Answers

This issue was actually the proxy variables. While the console was picking up the changes, PHP required a system restart to pick it up. So unsetting the environment variables and restarting allowed the Composer installer to retrieve the required files. Thanks Seldaek for your recommendation to check the proxy.

like image 196
Andrew Riker Avatar answered Sep 18 '22 04:09

Andrew Riker


Below is the Error,which normally occurs if your proxy settings are there

Solution 1

  • Ensure you have connectivity try ping www.google.com

Solution 2

- Remove Proxy settings ,they could be ones causing it,if outside a corporate network

Solution 3

  • Add the corporate proxy setting if on a corporate network

    • set http_proxy=http://your_proxy:your_port
    • set http_proxy=http://username:password@your_proxy:your_port
    • set https_proxy=https://your_proxy:your_port
    • set https_proxy=https://username:password@your_proxy:your_port
like image 34
Fred Ondieki Avatar answered Sep 21 '22 04:09

Fred Ondieki