[英]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.