Thursday, December 9, 2010

PHP Fatal error: Uncaught CurlException: 6: name lookup timed out thrown in Facebook

If you are facebook developer, and are using the latest facebook php sdk, facebook.php grabbed from github.com, and are facing the problem similiar to as defined below:

PHP Fatal error: Uncaught CurlException: 6: name lookup timed out thrown in //facebook.php on line 592

This is probably the host is not given enough time to contact with facebook server. To solve this problem, open facebook.php with your editor, and go to line 89 to find the code below:

1
2
3
4
5
6
public static $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-2.0',
);

Modify CURLOPT_CONNECTION to increase its value to, 30 or higher.

1
CURLOPT_CONNECTTIMEOUT => 30,

and test your facebook application again to see if it works.

Suggestion: Change to a better host to resolve the problem without modifying the facebook.php script