I\'m running PHP on a CentOS virtual machine under MacOS X, and any cURL request consistently takes 15s to run:
$c =
The problem was an IPv6 lookup failing on my machine. The solution:
Changed /etc/resolv.conf
to:
nameserver 8.8.8.8
nameserver 8.8.4.4
After rebooting, resolv.conf
got overwritten, so adding this line to /etc/sysconfig/network-scripts/ifcfg-eth0
(which was using BOOTPROTO=dhcp
) fixed the problem:
PEERDNS=no
And everything now works like a charm.
As an alternative, if you experience this problem on a server on which you can not change the configuration, configure cURL this way:
curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);