Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
    
What does dig example.com 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: ;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 '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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.