1

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 http://server.host.com:8080/login

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

Can anyone shed any light on this issue?

Thanks!

4
  • What does dig example.com return when run on the remote host?
    – Ladadadada
    May 31, 2012 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? May 31, 2012 at 21:54
  • @Ladadadada: ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61127 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0 ;; QUESTION SECTION: ;example.com. IN A ;; ANSWER SECTION: example.com. 62043 IN A 192.0.43.10 ;; AUTHORITY SECTION: example.com. 62043 IN NS a.iana-servers.net. example.com. 62043 IN NS b.iana-servers.net.
    – user101289
    May 31, 2012 at 22:01
  • It's the same reason you can't mail a package to a phone number. Jun 1, 2012 at 1:34

1 Answer 1

4

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.

1
  • 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, 2012 at 22:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .