force ipv4 php curl

curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );

 

If you encounter this problem with file_get_contents(), get_headers(), etc. you can try to recompile PHP using –disable-ipv6 option to ./configure.

Or you can add the following lines in /etc/sysctl.conf :

#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Or

echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6

 

when performing curl queries with php the ipv6 version of a site may be served even thought it’s not ready, which causes 503 or 404 errors. force ipv4 until ipv6 routing is stable.

 

ipv6.google.com/sorry/IndexRedirect glype

Leave a Reply