使用laravel-goutte爬取数据时遇cURL error 7连接拒绝问题求助
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:
If you see values here, temporarily unset them with:echo $HTTP_PROXY echo $HTTPS_PROXYunset 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.
- On Linux/macOS, run these commands in your terminal:
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 --listLook for
http-proxyorhttps-proxyentries. If they exist and aren't needed, unset them with:composer config -g --unset http-proxy composer config -g --unset https-proxyVerify 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.
- Linux/macOS:
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

