You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用laravel-goutte爬取数据时遇cURL error 7连接拒绝问题求助

Fixing cURL Error 7 with laravel-goutte (Connection Refused on Port 1080)

Hey there, let's figure out why you're hitting this cURL error 7 when using laravel-goutte. The error mentions failing to connect to getcomposer.org on port 1080, which is strange because your code is targeting http://www.q-manager.com/—here's the breakdown and fixes:

What's Causing This?

Chances are your system or Laravel environment has a global proxy configuration pointing to port 1080, but that proxy service isn't running, or the setup is incorrect. Goutte relies on Guzzle under the hood, and Guzzle will inherit system-wide proxy settings by default. So instead of connecting directly to q-manager.com, it's trying to route the request through the 1080 proxy, which is refusing the connection.

Step-by-Step Solutions

  • Check and Disable Global Proxy
    First, verify if your system has HTTP/HTTPS proxy env variables set:

    • On Linux/macOS, run these commands in your terminal:
      echo $HTTP_PROXY
      echo $HTTPS_PROXY
      
      If you see values here, temporarily unset them with:
      unset HTTP_PROXY HTTPS_PROXY
      
    • On Windows, go to Settings > Network & Internet > Proxy and turn off any manual proxy configurations, or confirm the proxy service is active.
      Then re-run your Laravel code to test if the error goes away.
  • Force Goutte to Skip Proxy
    If you can't disable the global proxy, explicitly tell Guzzle to ignore it by creating a custom client for Goutte:

    // Import the Guzzle Client class at the top of your controller
    use GuzzleHttp\Client;
    
    // In your method
    $client = new Client([
        'proxy' => null, // Disable proxy entirely
        'verify' => false, // Only add this if you hit SSL issues (not recommended for production)
    ]);
    
    $crawler = Goutte::setClient($client)->request('GET', 'http://www.q-manager.com/');
    

    This overrides any inherited proxy settings and makes Goutte connect directly to the target site.

  • Check Composer Proxy Configurations
    Sometimes Composer's global proxy settings can bleed into your Laravel app's HTTP requests. Run this command to list Composer's global config:

    composer config -g --list
    

    Look for http-proxy or https-proxy entries. If they exist and aren't needed, unset them with:

    composer config -g --unset http-proxy
    composer config -g --unset https-proxy
    
  • Verify Port 1080 Proxy Service (If Needed)
    If you actually need to use a proxy on port 1080, confirm the proxy service (like Shadowsocks, etc.) is running:

    • Linux/macOS:
      netstat -an | grep 1080
      
    • Windows:
      netstat -ano | findstr :1080
      

    If no results appear, start the proxy service and try your code again.

Quick Note for Production

Avoid using 'verify' => false in production environments—it disables SSL certificate verification, which is a security risk. Only use it temporarily for testing, and fix the root proxy/SSL issue long-term.

内容的提问来源于stack exchange,提问作者Anil Kumar Sahu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:35:20