0

I'm trying to make an FTP connection to 3 web sites on the same server via a PHP script. It works fine for 2 of the sites, but the 3rd I get the following error (and it doesn't appear to be temporary):

"Warning: ftp_connect() [function.ftp-connect]: php_network_getaddresses: getaddrinfo failed: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server"

This code snippet is where it fails:

$server = 'ftp.'.$ftp_server;
$conn_id = ftp_connect($server) OR die("<br>unable to establish an FTP connection");

I'm hoping someone can point me in the right direction.

Regards to all

4

2 回答 2

5

That means the DNS lookup for the ftp server's name (e.g. example.com) failed to resolve and the IP address could not be determined.

This could either be from your remote site's DNS servers being down, or the domain itself is misconfigured and is pointing at non-existing/unreachable DNS servers.

于 2012-05-01T21:28:21.303 回答
1

Perhaps the DNS servers for that specific host are down; check whois records for the domain to discover which DNS servers are authoritative, then check each one of them in turn with host to make sure they all resolve.

For example, whois stackoverflow.com:

Name Servers:
ns1.serverfault.com
ns2.serverfault.com
ns3.serverfault.com

Then:

$ host www.stackoverflow.com ns1.serverfault.com
Using domain server:
Name: ns1.serverfault.com
Address: 64.34.119.33#53
Aliases: 

www.stackoverflow.com is an alias for stackoverflow.com.
stackoverflow.com has address 64.34.119.12
stackoverflow.com mail is handled by 10 STACKOVERFLOW.COM.S9A1.PSMTP.com.
stackoverflow.com mail is handled by 20 STACKOVERFLOW.COM.S9A2.PSMTP.com.
stackoverflow.com mail is handled by 30 STACKOVERFLOW.COM.S9B1.PSMTP.com.
stackoverflow.com mail is handled by 40 STACKOVERFLOW.COM.S9B2.PSMTP.com.
$ host www.stackoverflow.com ns2.serverfault.com
Using domain server:
Name: ns2.serverfault.com
Address: 64.34.119.34#53
Aliases: 

www.stackoverflow.com is an alias for stackoverflow.com.
stackoverflow.com has address 64.34.119.12
stackoverflow.com mail is handled by 30 STACKOVERFLOW.COM.S9B1.PSMTP.com.
stackoverflow.com mail is handled by 40 STACKOVERFLOW.COM.S9B2.PSMTP.com.
stackoverflow.com mail is handled by 10 STACKOVERFLOW.COM.S9A1.PSMTP.com.
stackoverflow.com mail is handled by 20 STACKOVERFLOW.COM.S9A2.PSMTP.com.
$ host www.stackoverflow.com ns3.serverfault.com
Using domain server:
Name: ns3.serverfault.com
Address: 69.59.196.217#53
Aliases: 

www.stackoverflow.com is an alias for stackoverflow.com.
stackoverflow.com has address 64.34.119.12
stackoverflow.com mail is handled by 30 STACKOVERFLOW.COM.S9B1.PSMTP.com.
stackoverflow.com mail is handled by 40 STACKOVERFLOW.COM.S9B2.PSMTP.com.
stackoverflow.com mail is handled by 10 STACKOVERFLOW.COM.S9A1.PSMTP.com.
stackoverflow.com mail is handled by 20 STACKOVERFLOW.COM.S9A2.PSMTP.com.
$ 

All three servers responded to requests for www.stackoverflow.com, so all three servers are functional.

于 2012-05-01T21:31:01.430 回答