PHP error: php_network_getaddresses: getaddrinfo failed: (while getting information from other site.)

后端 未结 11 1108
时光说笑
时光说笑 2020-12-01 10:18

Trying to get information from an external source, I\'m receiving the following error:

Warning: php_network_getaddresses: getaddrinfo

相关标签:
11条回答
  • 2020-12-01 10:46

    I think that you should try replacing php7.3-curl with api.hostip.info/?ip=$ip&position=true . Hope this helps

    0 讨论(0)
  • 2020-12-01 10:48

    If you can discount transient outages on the remote server you are trying to connect to, then that just leaves the local network config as a problem.

    Using the IP address instead of the hostname is only going to work for the default domain on the remote host.

    What happens when you try using www.google.com (or its IP address)? If you stil can't connect, then its something to do with the network between your server and the outside world.

    0 讨论(0)
  • 2020-12-01 10:53

    Although this is a old thread, I have come across the same error recently while running nslookup in CentOS 7 and google search led me to some of the discussions in SO including this one. However, adding the nameservers entries to /etc/resolv.conf alone did not help as the nameserver values in resolv.conf were overwritten by the NetworkManager with the default DNS nameservers that are in the eth profile associated to the ethernet IP config.

    As mentioned by @m-canvar, set the following entries in /etc/resolv.conf

    search yourdomain.com
    nameserver 8.8.8.8
    nameserver 4.2.2.1
    nameserver 8.8.4.4
    

    To prevent overwriting these entries by NetworkManager, there are two two approaches:

    Option 1: Either set NM_CONTROLLED=no in the eth profile associated to the IPv4/IPv6 profile.

    Option 2: Disable NetworkManager service from running.

    chkconfig NetworkManager off
    service NetworkManager stop
    

    More details can be referred in my post about this error and solution.

    0 讨论(0)
  • 2020-12-01 10:56

    I faced this issue, while connecting DB, the variable to connect to db was not defined.

    Cause: php tried to connect to the db with undefined variable for db host (localhost/127.0.0.1/... any other ip or domain) but failed to trace the domain.

    Solution: Make sure the db host is properly defined.

    0 讨论(0)
  • 2020-12-01 10:57

    In my case(my machine is ubuntu 16), I append /etc/resolvconf/resolv.conf.d/base file by adding below ns lines.

    nameserver 8.8.8.8
    nameserver 4.2.2.1
    nameserver 2001:4860:4860::8844
    nameserver 2001:4860:4860::8888
    

    then run the update script,

    resolvconf -u
    
    0 讨论(0)
  • 2020-12-01 10:57

    In my case this was being issued by wp cli, and the problem was that I didn't have php7.3-curl installed. Fixed with: apt-get install -y --quiet php7.3-curl

    0 讨论(0)
提交回复
热议问题