composer failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known

11,229

Solution 1

This issue was posted about 2 years ago but I wanna answer this problem so no one should have difficulty like me.

First open /etc/resolv.conf

(if you using Ubuntu distributions, the file is /etc/resolvconf/resolv.conf.d/head)

# cat /etc/resolve.conf

And after that, write this rows to the file:

# Google's public DNS servers
nameserver 8.8.8.8    # Primary DNS server
nameserver 8.8.4.4    # Secondary DNS server

These are the Google's public DNS servers as mentioned in the code above.

Save and close.

After restart the network service using this command:

service network restart

This solved my problem.

Hope help to others...

Solution 2

In my case was a dns misconfiguration in Vagrant VM.

Updating DNS in /etc/resolv.conf solved my issue: https://askubuntu.com/questions/897270/dns-cannot-resolve-hosts

hope this will help other users

Solution 3

I fixed the issue on Linux/Centos6 (Plesk Onyx) by:

Opening /etc/resolv.conf (my file was empty)

Added: nameserver 8.8.8.8 nameserver 8.8.4.4

options rotate options timeout:3

Hopefully this helps someone out there.

Share:
11,229
DINA TAKLIT
Author by

DINA TAKLIT

Nothing in life is to be feared, it's only to be understood. Now is the time to understand more, so that we may fear Less. "Marie CURIE"

Updated on June 09, 2022

Comments

  • DINA TAKLIT
    DINA TAKLIT almost 2 years

    I'm new in lumen and i have done

    composer clear-cache then after

    composer update

    to install some package after configurating composer.json however i have got this error:

    [Composer\Downloader\TransportException]                                     
      The "http://packagist.org/p/phpunit/php-timer%24be3efc71adf134c858c1add0117  
      f060f4ab545fe9d357983c7bea165b2008d65.json" file could not be downloaded: p  
      hp_network_getaddresses: getaddrinfo failed: Name or service not known       
      failed to open stream: php_network_getaddresses: getaddrinfo failed: Name o  
      r service not known  
    

    Plase how could i fix this error