cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

curl error 6 Couldn't resolve host in PHP

From: Adam Stelmack <adam_at_phidgets.com>
Date: Fri, 31 Oct 2008 12:36:24 -0600

Hi,

Have been trying to get curl working on our new server and redesigned
site. Server is openBSD4.3, php and curl installed from packages. PHP
version 5.2.5, curl version libcurl/7.17.1 OpenSSL/0.9.7j zlib/1.2.3
libidn/1.1.

Trying to connect to a credit card processing company's testbed
environment, however curl seems to never be able to resolve the hostname
when run through PHP. I have been able to telnet and ping the hostname
and it has resolved without issue. Was even able to resolve and connect
when I just ran curl on the command line just fine. The problem only
seems to be when trying to use the PHP curl implementation. Have been
searching on google and a little bit on the archives for possible
solutions and come up empty. All solutions I have found degraded to
"it's your hosting company, their DNS is broken" however, this is an
internal server and the only thing having trouble resolving dns is this
webserver and ONLY when trying to use curl in PHP.

Code is as follows, pretty straightforward (leaving out url for security
reasons, but url is properly formed, I have tested it):

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_VERBOSE, 1);
  curl_setopt ($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS,$dataToSend);
  curl_setopt($ch,CURLOPT_TIMEOUT,$gArray['CLIENT_TIMEOUT']);
  curl_setopt($ch,CURLOPT_USERAGENT,$gArray['API_VERSION']);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

  $response=curl_exec ($ch);

I doubt seeing the code will help, but thought I would be thorough. Has
anyone ever come across this issue and perhaps managed to stumble across
a solution? It's rather irritating as our current live site works fine,
but the versions and install conditions I am sure are totally different
and hard to replicate at this point.
Thanks in advance for any replies!

-- 
Adam Stelmack
Developer and Webmaster
Phidgets Inc.
www.phidgets.com
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-10-31