1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Curl Proxy Issues - Can't Figure This One Out - "cURL Error (7): couldn't connect to host"

Discussion in 'PHP & Perl' started by cody41, Apr 26, 2013.

  1. cody41

    cody41 Power Member

    Joined:
    Jun 18, 2009
    Messages:
    682
    Likes Received:
    274
    Location:
    Texas
    I've got php code that utilizes a random known GOOD google passed proxy to reach out and parse through google serps for keyword positioning. I've run this code on my developer's web server (which I believe is based in Taiwan if that matters) and the proxies work, and the google checkup works. Ok, so code proven out and proxies proven out.

    What doesn't work is if I run the code from MY webserver in my Texas colocation or even off of my laptop at home running XAMPP. I get "cURL Error (7): couldn't connect to host" errors all the time.
    It's not my connecttime, it's not that it's a bad proxy and my outbound ports are not blocked (especially at home!). Any ideas?
     
  2. Dark Lord

    Dark Lord Junior Member

    Joined:
    Nov 2, 2009
    Messages:
    140
    Likes Received:
    57
    Have you reached a conclusion on this problem?
     
  3. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,879
    Likes Received:
    1,932
    Check that the firewall is not blocking the connection.
     
  4. stfuplease

    stfuplease Newbie

    Joined:
    Jun 25, 2013
    Messages:
    20
    Likes Received:
    24
    Some questions that should help to pinpoint the issue:
    1) The proxy - are you connecting to it by IP address or hostname?
    2) Are you able to connect to the proxy manually from your server?
    3) Are you sure that you have error_reporting and display_errors both set properly on your server?
    4) Are the two configurations identical (namely, php.ini)?


    If the answer to 1 is hostname, try manually resolving it and connecting to the IP instead to see if that fixes it.


    If you're unsure about #2, try this (can't paste code directly due to filters):
    Code:
    pastebin[i].[/i]co[b]m[/b][b]/[/b]7vim9Zxt

    If you're unsure of #3, at the top of the PHP script, add the following:
    Code:
     [b]/[/b][b]/[/b] TURN ON ERROR REPORTING
    ini_set("display_errors", "On");
    ini_set("log_errors", "On");
    error_reporting(E_ALL);

    Lastly, if you're unable to connect to the proxy using sockets/etc, try to ping it and see what your results are (assuming it responds to ping from the developer's machine as well).