antihate antihate - 4 months ago 33
PHP Question

curl with multiple proxies working on local server but not on live server

I've this code that works fine on my local server but doesn't work on live server.

I'm trying to scrap without getting blocked.

if a proxy get blocked by the remote server then how come its working on my local server?

function curl_se($set_url,$proxy){

$ch = curl_init($set_url);
//set options
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Pragma: "; //browsers keep this blank.
//set options
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20100401 Firefox/3.6.3");
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
echo "<pre>";
echo "</pre>";
return false;
return $result;


looping one proxy on each curl request.

$proxy = array(

On live server I'm getting curl error 7 (CURLE_COULDNT_CONNECT)

I'm stuck, its the same code same url working fine locally.

Kindly help me out!

Update: I figured out that its something to do with proxy, I tried hundreds of them none is working on live server getting curl error no 7; tried different website urls too.
while same proxy and urls working on my local server.


Try working proxies. check here ( your server is running just fine
when you use anonymous proxy then server can't see or block your real ip