无法连接到端口8080:连接被拒绝错误编号:7(cURL) [英] Failed to connect to port 8080: Connection refused Error number: 7 (cURL)

查看:1075
本文介绍了无法连接到端口8080:连接被拒绝错误编号:7(cURL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码-

  $ url ='http://52.77.156.123:8080/LebuPay/check -付款'; 

$ ch = curl_init($ url);

$ data = array(
successURL =>'http://jsonviewer.stack.hu',
failureURL =>'http:// jsonviewer.stack.hu',
金额 => $ a $,
orderTransactionID => $ order_id,
名字 =>,
lastName =>,
email =>,
mobileNumber =>,
accessKey => some_random_key
);

$ jsonEncode = json_encode($ data);

curl_setopt($ ch,CURLOPT_POST,TRUE);
curl_setopt($ ch,CURLOPT_POSTFIELDS,$ jsonEncode);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ ch,CURLOPT_HEADER,TRUE);
curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ ch,CURLOPT_HTTPHEADER,array(’Content-Type:application / json’));

$ result = curl_exec($ ch);
$ result = json_decode($ result,true);

echo错误CURL:。 curl_error($ ch)。 \n错误编号:。
curl_errno($ ch);

curl_close($ ch);


$ token = $ result ['token'];
标头(位置:http://52.77.156.123:8080/LebuPay/execute-payment?token=$token);

该代码在我的本地主机上有效,但是当我将其上传到服务器(Godaddy linux)上时。它给我错误无法连接到52.77.156.123端口8080:连接被拒绝,错误号:7



我尝试从中获取响应的API托管在AWS。



有什么办法可以解决这个问题吗?谢谢。

解决方案

由于更换服务器时会发生问题,因此我怀疑问题是出站服务器阻塞了端口。 / p>

这是一个很老的论坛帖子说:


我不知道它是否适用于其他任何内容而不是共享主机,但Godaddy共享主机具有除80外的所有传出端口,这些端口都被防火墙阻止了



问题在于,Godaddy共享主机不允许您从您的站点发出除80外的任何端口的请求。



这就像有一所房子,除了前门外,所有的门窗都焊接在一起。


并且


与Godaddy支持人员联系,并被告知端口80 80即使在其专用服务器上也被阻止。


在此期间,这可能已经改变了,但是由于您遇到了问题,我不知道






可能的解决方案:




  • 不要使用糟糕的托管服务(Godaddy的声誉很差)

  • 以某种方式说服Godaddy开放港口

  • 找到一个可以让您使用端口80将请求发送到Godaddy网络之外的代理


I have the following code -

$url = 'http://52.77.156.123:8080/LebuPay/check-payment';

$ch = curl_init($url);

$data = array(
"successURL"  =>  'http://jsonviewer.stack.hu',
"failureURL"  =>   'http://jsonviewer.stack.hu',
"amount"  => $amount,
"orderTransactionID"  => $order_id,
"firstName" =>   "",
"lastName"  =>  "",
"email" => "",
"mobileNumber"  => "",
"accessKey" =>  "some_random_key"
);

$jsonEncode = json_encode($data);

curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonEncode);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

$result = curl_exec($ch);
$result = json_decode($result, true);

echo "Error CURL: " . curl_error($ch) . " \nError number: " . 
curl_errno($ch);

curl_close($ch);


$token = $result['token'];
header("location: http://52.77.156.123:8080/LebuPay/execute-payment?token=$token");

The code works on my localhost but when I upload it on the server (Godaddy linux). It gives me error "Failed to connect to 52.77.156.123 port 8080: Connection refused Error number: 7"

The API I'm trying to get response from is hosted on AWS.

Any idea how I can solve this problem? Thanks.

解决方案

Since the problem occurs when you changed the server, I would suspect that the problem is the outgoing server blocking the port.

This, admittedly old, forum post says:

I don't know if it applies to anything other than shared hosting, but Godaddy shared hosting has all outgoing ports other than 80 blocked by their firewall

and

The problem is that Godaddy shared hosting will not let you make requests from your site that go to any port other than 80.

It's like having a house where all of the doors and windows, except the front door, are welded shut.

and

Talked to Godaddy Support and was told port 8080 is blocked, even on their dedicated servers.

This might have changed in the meantime, but since you are experiencing the problem I don't think it has.


Possible solutions:

  • Don't use awful hosting (Godaddy has a terrible reputation)
  • Somehow persuade Godaddy to open up the port
  • Find a proxy that lets you use port 80 to get the request outside of Godaddy's network

这篇关于无法连接到端口8080:连接被拒绝错误编号:7(cURL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆