![](/img/trans.png)
[英]cURL error 7: Failed to connect to 'x.xx.xxx.xx' port 9090: Connection refused
[英]php curl Failed to connect to xxx port 5001: Connection refused
这是我的网址: http://xxx:5001/?messageId=2&baseId=1
如果我在浏览器中打开它,工作正常。
但是如果我用 curl 打开它,我会收到错误:
php curl 无法连接到 xxx 端口 5001:连接被拒绝
我的php代码:
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'http://xxx:5001/?messageId=2&baseId=1');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$res = curl_exec($ch);
echo curl_error($ch);;
print_r($res);
curl_close($ch);
端口 5001 被防火墙打开,IP 未被服务器阻止
我在我的本地机器上运行了代码,它工作正常。 请尝试以下操作:
>PHP script.php
上运行脚本并检查错误#tail -f /var/log/error_log
您将在这 4 个步骤之一中找到答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.