Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to connect to a webservice using a PHP wrapper (which is using curl under the covers).

On my local linux machine running PHP 5.3 it works perfectly. However, when I move to a remote server (also running PHP 5.3 on Linux) the call the the webservice URL returns:

getaddrinfo(3) failed for

But when I issue a curl request from the command line, it returns the expected URL.

Can anyone shed any light on this issue?


share|improve this question
What does dig return when run on the remote host? – Ladadadada May 31 '12 at 21:51
What format is <URL> in - is it just the hostname, or a URL with http:// and/or anything after the hostname like a port number or trailing slash? – Shane Madden May 31 '12 at 21:54
more info added in edits. Thanks – user101289 May 31 '12 at 21:56
@Ladadadada: ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61127 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0 ;; QUESTION SECTION: ; IN A ;; ANSWER SECTION: 62043 IN A ;; AUTHORITY SECTION: 62043 IN NS 62043 IN NS – user101289 May 31 '12 at 22:01
It's the same reason you can't mail a package to a phone number. – David Schwartz Jun 1 '12 at 1:34
up vote 4 down vote accepted

That's expected. The ping command accepts either an IP address or a hostname and not a URL. Same goes for getaddrinfo() and getnameinfo() functions.

curl works because it is supposed to work with URLs.

share|improve this answer
I've removed the ping statement in the question, since as you point out it doesn't have anything to do with curl failing. Thanks – user101289 Jun 1 '12 at 22:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.