1
$url = 'http://google.com';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, '1');
$states = curl_exec($curl);
echo curl_error($curl);
curl_close($curl);

returns Failed to connect to 178.62.8.233 port 1080: Connection refused

3
  • None of that code should try to connect to port 1080. Do you have a proxy configured? Commented Jul 2, 2018 at 20:18
  • I don't think 178.62.8.233 has anything to do with Google. Commented Jul 2, 2018 at 20:19
  • I checked proxy settings. They were set to auto Commented Jul 3, 2018 at 19:40

1 Answer 1

1

try this:

$url = 'http://google.com';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FAILONERROR, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);   
$states = curl_exec($curl);
var_dump($states);
curl_close($curl);
Sign up to request clarification or add additional context in comments.

3 Comments

I don't know if it works, but I found the solution. I just use file_get_contents()
good jobs mate. if you want to explore more request like set header, coookie, proxy, etc. use curl is recomendation.
I found http_proxy environment variable with a value of 178.62.8.233. So I think that was the actual reason for that response

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.