0

When I use the curl functions in php, I always get this error:

"Failed to connect to www.google.de port 80: Connection timed out"

if I do the same on the command line: it works fine...

Any ideas why?

My Code:

$ch = curl_init('http://www.google.de');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1001);
$data = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);

My php.ini curl settings:

cURL support  enabled
cURL Information  7.35.0
Age  3
Features
AsynchDNS  Yes
CharConv  No
Debug  No
GSS-Negotiate  Yes
IDN  Yes
IPv6  Yes
krb4  No
Largefile  Yes
libz  Yes
NTLM  Yes
NTLMWB  Yes
SPNEGO  No
SSL  Yes
SSPI  No
TLS-SRP  Yes
Protocols  dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, smtp, smtps, telnet, tftp
Host  x86_64-pc-linux-gnu
SSL Version  OpenSSL/1.0.1f
ZLib Version  1.2.8 
A Coder Gamer
  • 840
  • 1
  • 10
  • 31
knete
  • 113
  • 1
  • 7
  • This one might be related: http://stackoverflow.com/questions/13813667/php-curl-timing-out-but-cli-curl-works?rq=1 – fvu May 23 '16 at 16:04
  • Increase or remove the `CURLOPT_TIMEOUT_MS` option and does it work? – drew010 May 23 '16 at 16:44
  • No it doesn't work with increasing or removing CURLOPT_TIMEOUT_MS anyway. And the link of fvu does not help me... – knete May 24 '16 at 06:56
  • i also get a timeout by using file_get_contents() instead of curl_init() – knete May 24 '16 at 12:22
  • ok, i found out that i am behind a proxy...that was the error...and the proxy was set for the os – knete May 24 '16 at 12:32

0 Answers0