Home » Php » PHP – Installing Composer – failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known

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

Posted by: admin July 12, 2020 Leave a comment

Questions:

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

How to&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.

Answer:

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

Answer:

mysqli_connect('root','', 'localhost', 'people');

You are passing root in as hostname.

try this

mysqli_connect('localhost','root', '', 'people');

this will connect to localhost with username root passwoord “” and default database people.

maybe better to change localhost with 127.0.0.1