Error in cURL request: name lookup timed out

Abdoljabbar picture Abdoljabbar · Oct 31, 2012 · Viewed 35.8k times · Source

I wrote some code that fill a login form and submit it via post method. Like:

    $config = array(
        'adapter' => 'Zend_Http_Client_Adapter_Curl',
    );      

    $this->siteObj = new Zend_Http_Client('http://example.com', $config);
    $this->siteObj->setCookieJar();
    $this->siteObj->setUri('http://example.com/login');
    $this->siteObj->setParameterPost( 'data[User][name]', 'user' );
    $this->siteObj->setParameterPost( 'data[User][password]', 'password' );
    $response = $this->siteObj->request('POST');

its works fine, but some times this error occur:

Error in cURL request: name lookup timed out

Error: An Internal Error Has Occurred.

whats the problem? what can I do to solve it?

Answer

herderwu picture herderwu · Oct 13, 2014

I encountered the same problem:

  • From the shell, curl worked.
  • From the shell, the PHP script worked.
  • PHP could not ping the website.
  • The DNS config was right.

After restarting Apache, it worked. So strange.